file_name
stringlengths 6
86
| file_path
stringlengths 45
249
| content
stringlengths 47
6.26M
| file_size
int64 47
6.26M
| language
stringclasses 1
value | extension
stringclasses 1
value | repo_name
stringclasses 767
values | repo_stars
int64 8
14.4k
| repo_forks
int64 0
1.17k
| repo_open_issues
int64 0
788
| repo_created_at
stringclasses 767
values | repo_pushed_at
stringclasses 767
values |
---|---|---|---|---|---|---|---|---|---|---|---|
CrosshairLabelGenerator.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/main/java/org/jfree/chart/labels/CrosshairLabelGenerator.java | /* ===========================================================
* 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.]
*
* ----------------------------
* 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 (<code>null</code> not permitted).
*
* @return The label (possibly <code>null</code>).
*/
public String generateLabel(Crosshair crosshair);
}
| 2,003 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
StandardXYItemLabelGenerator.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/main/java/org/jfree/chart/labels/StandardXYItemLabelGenerator.java | /* ===========================================================
* 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.]
*
* ---------------------------------
* StandardXYItemLabelGenerator.java
* ---------------------------------
* (C) Copyright 2001-2012, 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);
* 17-Jun-2012 : Removed JCommond dependencies (DG);
*
*/
package org.jfree.chart.labels;
import java.io.Serializable;
import java.text.DateFormat;
import java.text.NumberFormat;
import org.jfree.chart.util.PublicCloneable;
import org.jfree.data.xy.XYDataset;
/**
* 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 (<code>null</code> 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 (<code>null</code> not
* permitted).
* @param xFormat the format object for the x values (<code>null</code>
* not permitted).
* @param yFormat the format object for the y values (<code>null</code>
* 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 (<code>null</code>
* not permitted).
* @param xFormat the format object for the x values (<code>null</code>
* not permitted).
* @param yFormat the format object for the y values (<code>null</code>
* 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 (<code>null</code>
* not permitted).
* @param xFormat the format object for the x values (<code>null</code>
* permitted).
* @param yFormat the format object for the y values (<code>null</code>
* 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 (<code>null</code> not
* permitted).
* @param xFormat the format object for the x values (<code>null</code>
* not permitted).
* @param yFormat the format object for the y values (<code>null</code>
* 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 (<code>null</code> not permitted).
* @param series the series index (zero-based).
* @param item the item index (zero-based).
*
* @return The label text (possibly <code>null</code>).
*/
@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 (<code>null</code> 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);
}
}
| 7,915 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
ItemLabelPosition.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/main/java/org/jfree/chart/labels/ItemLabelPosition.java | /* ===========================================================
* 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.]
*
* ----------------------
* ItemLabelPosition.java
* ----------------------
* (C) Copyright 2003-2012, 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);
* 17-Jun-2012 : Removed JCommon dependencies (DG);
*
*/
package org.jfree.chart.labels;
import java.io.Serializable;
import org.jfree.chart.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 (<code>null</code> not
* permitted).
* @param textAnchor the text anchor (<code>null</code> 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 (<code>null</code> not
* permitted).
* @param textAnchor the text anchor (<code>null</code> not permitted).
* @param rotationAnchor the rotation anchor (<code>null</code> not
* permitted).
* @param angle the rotation angle (in radians).
*/
public ItemLabelPosition(ItemLabelAnchor itemLabelAnchor,
TextAnchor textAnchor,
TextAnchor rotationAnchor,
double angle) {
if (itemLabelAnchor == null) {
throw new IllegalArgumentException(
"Null 'itemLabelAnchor' argument.");
}
if (textAnchor == null) {
throw new IllegalArgumentException("Null 'textAnchor' argument.");
}
if (rotationAnchor == null) {
throw new IllegalArgumentException(
"Null 'rotationAnchor' argument.");
}
this.itemLabelAnchor = itemLabelAnchor;
this.textAnchor = textAnchor;
this.rotationAnchor = rotationAnchor;
this.angle = angle;
}
/**
* Returns the item label anchor.
*
* @return The item label anchor (never <code>null</code>).
*/
public ItemLabelAnchor getItemLabelAnchor() {
return this.itemLabelAnchor;
}
/**
* Returns the text anchor.
*
* @return The text anchor (never <code>null</code>).
*/
public TextAnchor getTextAnchor() {
return this.textAnchor;
}
/**
* Returns the rotation anchor point.
*
* @return The rotation anchor point (never <code>null</code>).
*/
public TextAnchor getRotationAnchor() {
return this.rotationAnchor;
}
/**
* Returns the angle of rotation for the label.
*
* @return The angle (in radians).
*/
public double getAngle() {
return this.angle;
}
/**
* Tests this object for equality with an arbitrary object.
*
* @param obj the object (<code>null</code> 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;
}
}
| 6,213 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
StandardXYZToolTipGenerator.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/main/java/org/jfree/chart/labels/StandardXYZToolTipGenerator.java | /* ===========================================================
* 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.]
*
* --------------------------------
* StandardXYZToolTipGenerator.java
* --------------------------------
* (C) Copyright 2004-2012, 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);
* 17-Jun-2012 : Removed JCommon dependencies (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.ObjectUtilities;
import org.jfree.data.xy.XYDataset;
import org.jfree.data.xy.XYZDataset;
/**
* 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 (<code>null</code>
* not permitted).
* @param yFormat the format object for the y values (<code>null</code>
* not permitted).
* @param zFormat the format object for the z values (<code>null</code>
* not permitted).
*/
public StandardXYZToolTipGenerator(String formatString,
NumberFormat xFormat,
NumberFormat yFormat,
NumberFormat zFormat) {
super(formatString, xFormat, yFormat);
if (zFormat == null) {
throw new IllegalArgumentException("Null 'zFormat' argument.");
}
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 (<code>null</code>
* not permitted).
* @param yFormat the format object for the y values (<code>null</code>
* not permitted).
* @param zFormat the format object for the z values (<code>null</code>
* not permitted).
*/
public StandardXYZToolTipGenerator(String formatString,
DateFormat xFormat,
DateFormat yFormat,
DateFormat zFormat) {
super(formatString, xFormat, yFormat);
if (zFormat == null) {
throw new IllegalArgumentException("Null 'zFormat' argument.");
}
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 <code>null</code>).
*/
public NumberFormat getZFormat() {
return this.zFormat;
}
/**
* Returns the date formatter for the z-values.
*
* @return The date formatter (possibly <code>null</code>).
*/
public DateFormat getZDateFormat() {
return this.zDateFormat;
}
/**
* Generates a tool tip text item for a particular item within a series.
*
* @param dataset the dataset (<code>null</code> not permitted).
* @param series the series index (zero-based).
* @param item the item index (zero-based).
*
* @return The tooltip text (possibly <code>null</code>).
*/
@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 (<code>null</code> not permitted).
* @param series the series (zero-based index).
* @param item the item (zero-based index).
*
* @return The label (possibly <code>null</code>).
*/
@Override
public String generateLabelString(XYDataset dataset, int series, int item) {
String result = null;
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 (<code>null</code> not permitted).
* @param series the series (zero-based index).
* @param item the item (zero-based index).
*
* @return The items (never <code>null</code>).
*/
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 (<code>null</code> 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;
}
}
| 8,793 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
StandardCrosshairLabelGenerator.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/main/java/org/jfree/chart/labels/StandardCrosshairLabelGenerator.java | /* ===========================================================
* 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.]
*
* ------------------------------------
* 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 (<code>null</code> not
* permitted).
* @param numberFormat the number formatter (<code>null</code> 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 <code>null</code>).
*/
public String getLabelTemplate() {
return this.labelTemplate;
}
/**
* Returns the number formatter.
*
* @return The formatter (never <code>null</code>).
*/
public NumberFormat getNumberFormat() {
return this.numberFormat;
}
/**
* Returns a string that can be used as the label for a crosshair.
*
* @param crosshair the crosshair (<code>null</code> not permitted).
*
* @return The label (possibly <code>null</code>).
*/
@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 (<code>null</code> 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();
}
}
| 4,857 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
PieSectionLabelGenerator.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/main/java/org/jfree/chart/labels/PieSectionLabelGenerator.java | /* ===========================================================
* 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.]
*
* -----------------------------
* 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 (<code>null</code> not permitted).
* @param key the section key (<code>null</code> not permitted).
*
* @return The label (possibly <code>null</code>).
*/
public String generateSectionLabel(PieDataset dataset, Comparable key);
/**
* Generates an attributed label for the specified series, or
* <code>null</code> 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:
* <ul>
* <li>{@link TextAttribute#FONT}: will set the font;</li>
* <li>{@link TextAttribute#POSTURE}: a value of
* {@link TextAttribute#POSTURE_OBLIQUE} will add {@link Font#ITALIC} to
* the current font;</li>
* <li>{@link TextAttribute#WEIGHT}: a value of
* {@link TextAttribute#WEIGHT_BOLD} will add {@link Font#BOLD} to the
* current font;</li>
* <li>{@link TextAttribute#FOREGROUND}: this will set the {@link Paint}
* for the current</li>
* <li>{@link TextAttribute#SUPERSCRIPT}: the values
* {@link TextAttribute#SUPERSCRIPT_SUB} and
* {@link TextAttribute#SUPERSCRIPT_SUPER} are recognised.</li>
* </ul>
*
* @param dataset the dataset.
* @param key the key.
*
* @return An attributed label (possibly <code>null</code>).
*/
public AttributedString generateAttributedSectionLabel(PieDataset dataset,
Comparable key);
}
| 4,356 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
IntervalCategoryItemLabelGenerator.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/main/java/org/jfree/chart/labels/IntervalCategoryItemLabelGenerator.java | /* ===========================================================
* 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.]
*
* ---------------------------------------
* IntervalCategoryItemLabelGenerator.java
* ---------------------------------------
* (C) Copyright 2004-2012, by Object Refinery Limited.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes
* -------
* 11-May-2004 : Version 1, split from IntervalCategoryItemLabelGenerator (DG);
* 17-Jun-2012 : Removed JCommon dependencies (DG);
*
*/
package org.jfree.chart.labels;
import java.io.Serializable;
import java.text.DateFormat;
import java.text.NumberFormat;
import org.jfree.chart.util.PublicCloneable;
import org.jfree.data.category.CategoryDataset;
import org.jfree.data.category.IntervalCategoryDataset;
/**
* 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 (<code>null</code> not
* permitted).
* @param formatter the number formatter (<code>null</code> 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 (<code>null</code> not
* permitted).
* @param formatter the date formatter (<code>null</code> not permitted).
*/
public IntervalCategoryItemLabelGenerator(String labelFormat,
DateFormat formatter) {
super(labelFormat, formatter);
}
/**
* Creates the array of items that can be passed to the
* <code>MessageFormat</code> class for creating labels.
*
* @param dataset the dataset (<code>null</code> not permitted).
* @param row the row index (zero-based).
* @param column the column index (zero-based).
*
* @return The items (never <code>null</code>).
*/
@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;
}
}
| 5,200 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
package-info.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/main/java/org/jfree/chart/demo/package-info.java | /**
* 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:
* <p>
* <a href="http://www.object-refinery.com/jfreechart/guide.html" target="_blank" rel="noopener noreferrer">
* http://www.object-refinery.com/jfreechart/guide.html
* </a>
*/
package org.jfree.chart.demo;
| 415 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
BarChartDemo1.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/main/java/org/jfree/chart/demo/BarChartDemo1.java | /* ===========================================================
* 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.]
*
* ------------------
* BarChartDemo1.java
* ------------------
* (C) Copyright 2003-2012, 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 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.NumberAxis;
import org.jfree.chart.plot.CategoryPlot;
import org.jfree.chart.renderer.category.BarRenderer;
import org.jfree.chart.ui.ApplicationFrame;
import org.jfree.chart.ui.RefineryUtilities;
import org.jfree.data.category.CategoryDataset;
import org.jfree.data.category.DefaultCategoryDataset;
import java.awt.*;
import java.awt.font.TextAttribute;
/**
* 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);
//stackChartPanel.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 with default settings...
JFreeChart chart = ChartFactory.createBarChart(
"Bar Chart Demo 1", // chart title
"Category", // domain axis label
"Value", // range axis label
dataset);
// 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.setLabelPaint(Color.RED);
domainAxis.setLabel("Category (H20)");
domainAxis.getLabel().addAttribute(TextAttribute.SUPERSCRIPT, TextAttribute.SUPERSCRIPT_SUB, 11, 12);
rangeAxis.setLabel("Value2");
rangeAxis.getLabel().addAttribute(TextAttribute.SUPERSCRIPT, TextAttribute.SUPERSCRIPT_SUPER, 5, 6);
// 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);
}
}
| 7,600 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
PieChartDemo1.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/main/java/org/jfree/chart/demo/PieChartDemo1.java | /* ===========================================================
* 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.]
*
* ------------------
* PieChartDemo1.java
* ------------------
* (C) Copyright 2003-2012, 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 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.ui.ApplicationFrame;
import org.jfree.chart.ui.RefineryUtilities;
import org.jfree.chart.plot.PiePlot;
import org.jfree.data.general.DefaultPieDataset;
import org.jfree.data.general.PieDataset;
/**
* 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.
*
* @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",
dataset);
PiePlot plot = (PiePlot) chart.getPlot();
plot.setSectionOutlinesVisible(false);
plot.setNoDataMessage("No data available");
return chart;
}
/**
* 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.setMouseWheelEnabled(true);
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("Pie Chart Demo 1");
demo.pack();
RefineryUtilities.centerFrameOnScreen(demo);
demo.setVisible(true);
}
}
| 4,797 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
TimeSeriesChartDemo1.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/main/java/org/jfree/chart/demo/TimeSeriesChartDemo1.java | /* ===========================================================
* 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.]
*
* -------------------------
* TimeSeriesChartDemo1.java
* -------------------------
* (C) Copyright 2003-2012, 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.ui.ApplicationFrame;
import org.jfree.chart.ui.RectangleInsets;
import org.jfree.chart.ui.RefineryUtilities;
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;
/**
* 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",
"Date", "Price Per Unit",
dataset);
chart.setBackgroundPaint(Color.WHITE);
XYPlot plot = (XYPlot) chart.getPlot();
plot.setBackgroundPaint(Color.LIGHT_GRAY);
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);
}
}
| 7,800 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
SelectionDemo5Category.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/main/java/org/jfree/chart/demo/selection/SelectionDemo5Category.java | /* ---------------------------
* SelectionDemo5Category.java
* ---------------------------
* (C) Copyright 2013, by Object Refinery Limited.
*
*/
package org.jfree.chart.demo.selection;
/**
* based on BarChartDemo1
*/
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.GradientPaint;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.JTable;
import javax.swing.border.EmptyBorder;
import javax.swing.border.TitledBorder;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableColumnModel;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
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.labels.StandardCategorySeriesLabelGenerator;
import org.jfree.chart.panel.selectionhandler.EntitySelectionManager;
import org.jfree.chart.panel.selectionhandler.MouseClickSelectionHandler;
import org.jfree.chart.panel.selectionhandler.RectangularRegionSelectionHandler;
import org.jfree.chart.panel.selectionhandler.RegionSelectionHandler;
import org.jfree.chart.plot.CategoryPlot;
import org.jfree.chart.renderer.category.BarRenderer;
import org.jfree.chart.renderer.item.IRSUtilities;
import org.jfree.chart.ui.ApplicationFrame;
import org.jfree.chart.ui.RefineryUtilities;
import org.jfree.data.category.CategoryDataset;
import org.jfree.data.category.DefaultCategoryDataset;
import org.jfree.data.extension.DatasetIterator;
import org.jfree.data.extension.DatasetSelectionExtension;
import org.jfree.data.extension.impl.CategoryCursor;
import org.jfree.data.extension.impl.CategoryDatasetSelectionExtension;
import org.jfree.data.extension.impl.DatasetExtensionManager;
import org.jfree.data.general.Dataset;
import org.jfree.data.general.SelectionChangeEvent;
import org.jfree.data.general.SelectionChangeListener;
public class SelectionDemo5Category extends ApplicationFrame
implements SelectionChangeListener<CategoryCursor<String, String>> {
private JTable table;
private DefaultTableModel model;
private CategoryDataset dataset;
public SelectionDemo5Category(String title) {
super(title);
JPanel chartPanel = createDemoPanel();
chartPanel.setPreferredSize(new Dimension(500, 270));
JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
split.add(chartPanel);
this.model = new DefaultTableModel(new String[] { "row:", "column:",
"value:"}, 0);
this.table = new JTable(this.model);
TableColumnModel tcm = this.table.getColumnModel();
JPanel p = new JPanel(new BorderLayout());
JScrollPane scroller = new JScrollPane(this.table);
p.add(scroller);
p.setBorder(BorderFactory.createCompoundBorder(new TitledBorder(
"Selected Items: "), new EmptyBorder(4, 4, 4, 4)));
split.add(p);
setContentPane(split);
}
/**
* 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;
}
private static JFreeChart createChart(CategoryDataset dataset, DatasetSelectionExtension<CategoryCursor<String, String>> ext) {
// create the chart...
JFreeChart chart = ChartFactory.createBarChart("Bar Chart Demo 1",
"Category", "Value", dataset);
CategoryPlot plot = (CategoryPlot) chart.getPlot();
plot.setDomainGridlinesVisible(true);
plot.setRangeCrosshairVisible(true);
plot.setRangeCrosshairPaint(Color.blue);
// 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);
renderer.setLegendItemToolTipGenerator(
new StandardCategorySeriesLabelGenerator("Tooltip: {0}"));
CategoryAxis domainAxis = plot.getDomainAxis();
domainAxis.setCategoryLabelPositions(
CategoryLabelPositions.createUpRotationLabelPositions(
Math.PI / 6.0));
//add selection specific rendering
IRSUtilities.setSelectedItemPaint(renderer, ext, Color.WHITE);
//register plot as selection change listener
ext.addChangeListener(plot);
return chart;
}
public final JPanel createDemoPanel() {
this.dataset = createDataset();
//extend dataset and add selection change listener for the demo
DatasetSelectionExtension<CategoryCursor<String, String>>
datasetExtension = new CategoryDatasetSelectionExtension<String, String>(this.dataset);
datasetExtension.addChangeListener(this);
//standard setup
JFreeChart chart = createChart(this.dataset, datasetExtension);
ChartPanel panel = new ChartPanel(chart);
panel.setMouseWheelEnabled(true);
// add a selection handler
RegionSelectionHandler selectionHandler
= new RectangularRegionSelectionHandler();
panel.addMouseHandler(selectionHandler);
panel.addMouseHandler(new MouseClickSelectionHandler());
panel.removeMouseHandler(panel.getZoomHandler());
// add a selection manager
DatasetExtensionManager dExManager = new DatasetExtensionManager();
dExManager.registerDatasetExtension(datasetExtension);
panel.setSelectionManager(new EntitySelectionManager(panel, new Dataset[] { this.dataset }, dExManager));
return panel;
}
public void selectionChanged(SelectionChangeEvent<CategoryCursor<String,
String>> event) {
while (this.model.getRowCount() > 0) {
this.model.removeRow(0);
}
CategoryDatasetSelectionExtension<String, String> ext
= (CategoryDatasetSelectionExtension<String, String>)
event.getSelectionExtension();
DatasetIterator<CategoryCursor<String, String>> iter
= ext.getSelectionIterator(true);
while (iter.hasNext()) {
CategoryCursor<String, String> dc = iter.next();
this.model.addRow(new Object[] { dc.rowKey, dc.columnKey,
dataset.getValue(dc.rowKey, dc.columnKey)});
}
}
public static void main(String[] args) {
SelectionDemo5Category demo = new SelectionDemo5Category(
"JFreeChart: SelectionDemo5.java");
demo.pack();
RefineryUtilities.centerFrameOnScreen(demo);
demo.setVisible(true);
}
}
| 8,830 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
SelectionDemo4.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/main/java/org/jfree/chart/demo/selection/SelectionDemo4.java | /* -------------------
* SelectionDemo4.java
* -------------------
* (C) Copyright 2004-2013, by Object Refinery Limited.
*
*/
package org.jfree.chart.demo.selection;
import java.awt.BorderLayout;
import java.awt.Color;
import java.util.Random;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.JTable;
import javax.swing.border.EmptyBorder;
import javax.swing.border.TitledBorder;
import javax.swing.table.DefaultTableModel;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.panel.selectionhandler.EntitySelectionManager;
import org.jfree.chart.panel.selectionhandler.FreePathSelectionHandler;
import org.jfree.chart.panel.selectionhandler.MouseClickSelectionHandler;
import org.jfree.chart.panel.selectionhandler.RegionSelectionHandler;
import org.jfree.chart.plot.XYPlot;
import org.jfree.chart.renderer.item.IRSUtilities;
import org.jfree.chart.renderer.xy.StandardXYBarPainter;
import org.jfree.chart.renderer.xy.XYBarRenderer;
import org.jfree.chart.ui.ApplicationFrame;
import org.jfree.chart.ui.RefineryUtilities;
import org.jfree.data.extension.DatasetIterator;
import org.jfree.data.extension.DatasetSelectionExtension;
import org.jfree.data.extension.impl.DatasetExtensionManager;
import org.jfree.data.extension.impl.XYCursor;
import org.jfree.data.extension.impl.XYDatasetSelectionExtension;
import org.jfree.data.general.Dataset;
import org.jfree.data.general.SelectionChangeEvent;
import org.jfree.data.general.SelectionChangeListener;
import org.jfree.data.statistics.HistogramDataset;
import org.jfree.data.statistics.SimpleHistogramBin;
import org.jfree.data.statistics.SimpleHistogramDataset;
import org.jfree.data.xy.IntervalXYDataset;
/**
* A demo of the {@link HistogramDataset} class.
*/
public class SelectionDemo4 extends ApplicationFrame implements
SelectionChangeListener<XYCursor> {
private SimpleHistogramDataset dataset;
private DefaultTableModel model;
private JTable table;
/**
* Creates a new demo.
*
* @param title the frame title.
*/
public SelectionDemo4(String title) {
super(title);
ChartPanel chartPanel = (ChartPanel) createDemoPanel();
chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
JFreeChart chart = chartPanel.getChart();
XYPlot plot = (XYPlot) chart.getPlot();
this.dataset = (SimpleHistogramDataset) plot.getDataset();
JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
split.add(chartPanel);
this.model = new DefaultTableModel(new String[] { "Item:",
"Bin Start:", "Bin End:", "Value:" }, 0);
this.table = new JTable(this.model);
JPanel p = new JPanel(new BorderLayout());
JScrollPane scroller = new JScrollPane(this.table);
p.add(scroller);
p.setBorder(BorderFactory.createCompoundBorder(new TitledBorder(
"Selected Items: "), new EmptyBorder(4, 4, 4, 4)));
split.add(p);
setContentPane(split);
}
/**
* The selection changed, so we change the table model.
*
* @param event
*/
public void selectionChanged(SelectionChangeEvent<XYCursor> event) {
while (this.model.getRowCount() > 0) {
this.model.removeRow(0);
}
XYDatasetSelectionExtension ext = (XYDatasetSelectionExtension) event
.getSelectionExtension();
DatasetIterator<XYCursor> iter = ext.getSelectionIterator(true);
while (iter.hasNext()) {
XYCursor dc = iter.next();
this.model.addRow(new Object[] { new Integer(dc.item),
this.dataset.getStartX(dc.series, dc.item),
this.dataset.getEndX(dc.series, dc.item),
this.dataset.getY(dc.series, dc.item) });
}
}
/**
* Creates a sample {@link HistogramDataset}.
*
* @return the dataset.
*/
private static IntervalXYDataset createDataset() {
SimpleHistogramDataset dataset = new SimpleHistogramDataset("H1");
double lower = 0.0;
for (int i = 0; i < 100; i++) {
double upper = (i + 1) / 10.0;
SimpleHistogramBin bin = new SimpleHistogramBin(lower, upper, true,
false);
dataset.addBin(bin);
lower = upper;
}
double[] values = new double[1000];
Random generator = new Random(12345678L);
for (int i = 0; i < 1000; i++) {
values[i] = generator.nextGaussian() + 5;
}
dataset.addObservations(values);
return dataset;
}
/**
* Creates a chart.
*
* @param dataset a dataset.
*
* @return The chart.
*/
private static JFreeChart createChart(IntervalXYDataset dataset,
DatasetSelectionExtension<XYCursor> ext) {
JFreeChart chart = ChartFactory.createHistogram("SelectionDemo4", null,
null, dataset);
XYPlot plot = (XYPlot) chart.getPlot();
plot.setDomainPannable(true);
plot.setRangePannable(true);
plot.setForegroundAlpha(0.85f);
NumberAxis yAxis = (NumberAxis) plot.getRangeAxis();
yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
XYBarRenderer renderer = (XYBarRenderer) plot.getRenderer();
renderer.setDrawBarOutline(true);
renderer.setDefaultOutlinePaint(Color.red);
renderer.setBarPainter(new StandardXYBarPainter());
renderer.setShadowVisible(false);
//add selection specific rendering
IRSUtilities.setSelectedItemPaint(renderer, ext, Color.white);
//register plot as selection change listener
ext.addChangeListener(plot);
return chart;
}
/**
* Creates a panel for the demo (used by SuperDemo.java).
*
* @return A panel.
*/
public final JPanel createDemoPanel() {
IntervalXYDataset xydataset = createDataset();
//extend dataset and add selection change listener for the demo
DatasetSelectionExtension<XYCursor> datasetExtension
= new XYDatasetSelectionExtension(xydataset);
datasetExtension.addChangeListener(this);
//standard setup
JFreeChart chart = createChart(xydataset, datasetExtension);
ChartPanel panel = new ChartPanel(chart);
panel.setMouseWheelEnabled(true);
// add a selection handler
RegionSelectionHandler selectionHandler
= new FreePathSelectionHandler();
panel.addMouseHandler(selectionHandler);
panel.addMouseHandler(new MouseClickSelectionHandler());
panel.removeMouseHandler(panel.getZoomHandler());
// add a selection manager with intersection selection
DatasetExtensionManager dExManager = new DatasetExtensionManager();
dExManager.registerDatasetExtension(datasetExtension);
EntitySelectionManager selectionManager = new EntitySelectionManager(
panel, new Dataset[] { xydataset }, dExManager);
selectionManager.setIntersectionSelection(true);
panel.setSelectionManager(selectionManager);
return panel;
}
/**
* The starting point for the demo.
*
* @param args ignored.
*/
public static void main(String[] args) {
SelectionDemo4 demo = new SelectionDemo4(
"JFreeChart: SelectionDemo4.java");
demo.pack();
RefineryUtilities.centerFrameOnScreen(demo);
demo.setVisible(true);
}
}
| 7,869 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
SelectionDemo7ScatterRenderer.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/main/java/org/jfree/chart/demo/selection/SelectionDemo7ScatterRenderer.java | /* ----------------------------------
* SelectionDemo7ScatterRenderer.java
* ----------------------------------
* (C) Copyright 2013, by Object Refinery Limited.
*
*/
package org.jfree.chart.demo.selection;
import java.awt.Color;
import java.awt.Shape;
import java.awt.geom.Rectangle2D;
import java.util.ArrayList;
import java.util.List;
import javax.swing.JPanel;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.ChartUtilities;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.CategoryAxis;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.panel.selectionhandler.EntitySelectionManager;
import org.jfree.chart.panel.selectionhandler.FreeRegionSelectionHandler;
import org.jfree.chart.panel.selectionhandler.MouseClickSelectionHandler;
import org.jfree.chart.panel.selectionhandler.RegionSelectionHandler;
import org.jfree.chart.plot.CategoryPlot;
import org.jfree.chart.renderer.category.ScatterRenderer;
import org.jfree.chart.renderer.item.DefaultShapeIRS;
import org.jfree.chart.ui.ApplicationFrame;
import org.jfree.chart.ui.RectangleInsets;
import org.jfree.chart.ui.RefineryUtilities;
import org.jfree.data.extension.DatasetSelectionExtension;
import org.jfree.data.extension.impl.CategoryCursor;
import org.jfree.data.extension.impl.CategoryDatasetSelectionExtension;
import org.jfree.data.extension.impl.DatasetExtensionManager;
import org.jfree.data.general.Dataset;
import org.jfree.data.statistics.DefaultMultiValueCategoryDataset;
import org.jfree.data.statistics.MultiValueCategoryDataset;
/*
* based on ScatterRendererDemo1
*/
public class SelectionDemo7ScatterRenderer extends ApplicationFrame {
/**
* Creates a new demo instance.
*
* @param title the frame title.
*/
public SelectionDemo7ScatterRenderer(String title) {
super(title);
JPanel chartPanel = createDemoPanel();
chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
setContentPane(chartPanel);
}
private static List<Number> listOfValues(double[] values) {
List<Number> result = new ArrayList<Number>();
for (int i = 0; i < values.length; i++) {
result.add(new Double(values[i]));
}
return result;
}
/**
* Creates a sample dataset.
*
* @return A dataset.
*/
private static MultiValueCategoryDataset createDataset() {
DefaultMultiValueCategoryDataset dataset
= new DefaultMultiValueCategoryDataset();
dataset.add(listOfValues(new double[] { 1.0, 2.0, 3.0 }), "Series 1",
"C1");
dataset.add(listOfValues(new double[] { 1.2, 2.2, 3.2 }), "Series 1",
"C2");
dataset.add(listOfValues(new double[] { 1.4, 2.4, 3.4 }), "Series 1",
"C3");
dataset.add(listOfValues(new double[] { 1.0, 2.1, 3.2 }), "Series 1",
"C1");
dataset.add(listOfValues(new double[] { 1.2, 2.15, 3.5 }), "Series 1",
"C2");
dataset.add(listOfValues(new double[] { 1.4, 2.5, 3.2 }), "Series 1",
"C3");
dataset.add(listOfValues(new double[] { 1.4, 3.0, 3.2 }), "Series 1",
"C3");
dataset.add(listOfValues(new double[] { 1.4, 3.0 }), "Series 2", "C1");
dataset.add(listOfValues(new double[] { 1.0, 3.0 }), "Series 2", "C1");
dataset.add(listOfValues(new double[] { 1.2, 3.2 }), "Series 2", "C2");
dataset.add(listOfValues(new double[] { 1.4, 3.6 }), "Series 2", "C3");
dataset.add(listOfValues(new double[] { 1.2, 3.1 }), "Series 2", "C1");
dataset.add(listOfValues(new double[] { 1.4, 3.4 }), "Series 2", "C2");
dataset.add(listOfValues(new double[] { 1.5, 3.6 }), "Series 2", "C3");
return dataset;
}
/**
* Creates a chart.
*
* @param dataset the dataset.
*
* @return A chart.
*/
private static JFreeChart createChart(final MultiValueCategoryDataset
dataset, final DatasetSelectionExtension<CategoryCursor
<String, String>> ext) {
ScatterRenderer r = new ScatterRenderer();
CategoryPlot plot = new CategoryPlot(dataset, new CategoryAxis(
"Category"), new NumberAxis("Value"), r);
plot.setBackgroundPaint(Color.lightGray);
plot.setDomainGridlinePaint(Color.white);
plot.setRangeGridlinePaint(Color.white);
plot.setAxisOffset(new RectangleInsets(4, 4, 4, 4));
JFreeChart chart = new JFreeChart("ScatterRendererDemo1", plot);
ChartUtilities.applyCurrentTheme(chart);
//register the plot
ext.addChangeListener(plot);
//illustrates the usage of a shape item rendering strategy
final CategoryCursor<String, String> cursor = new CategoryCursor<String,
String>();
r.setShapeIRS(new DefaultShapeIRS(r) {
private static final long serialVersionUID = 1L;
@Override
public Shape getItemShape(int row, int column) {
cursor.setPosition((String)dataset.getRowKey(row),
(String) dataset.getColumnKey(column));
if (ext.isSelected(cursor)) {
return new Rectangle2D.Double(-10.0, -10.0, 20.0, 20.0);
} else {
return super.getItemShape(row, column);
}
}
});
return chart;
}
/**
* Creates a panel for the demo (used by SuperDemo.java).
*
* @return A panel.
*/
public static JPanel createDemoPanel() {
MultiValueCategoryDataset dataset = createDataset();
//extend dataset and add selection change listener for the demo
DatasetSelectionExtension<CategoryCursor<String, String>>
datasetExtension = new CategoryDatasetSelectionExtension
<String, String>(dataset);
//standard setup
JFreeChart chart = createChart(dataset, datasetExtension);
ChartPanel panel = new ChartPanel(chart);
panel.setMouseWheelEnabled(true);
//add a selection handler with shift modifier for clicking
RegionSelectionHandler selectionHandler
= new FreeRegionSelectionHandler();
panel.addMouseHandler(selectionHandler);
panel.addMouseHandler(new MouseClickSelectionHandler());
panel.removeMouseHandler(panel.getZoomHandler());
// add a selection manager
DatasetExtensionManager dExManager = new DatasetExtensionManager();
dExManager.registerDatasetExtension(datasetExtension);
panel.setSelectionManager(new EntitySelectionManager(panel,
new Dataset[] { dataset }, dExManager));
return panel;
}
/**
* Starting point for the demonstration application.
*
* @param args ignored.
*/
public static void main(String[] args) {
SelectionDemo7ScatterRenderer demo = new SelectionDemo7ScatterRenderer(
"JFreeChart: ScatterRendererDemo1.java");
demo.pack();
RefineryUtilities.centerFrameOnScreen(demo);
demo.setVisible(true);
}
}
| 7,304 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
SelectionDemo8.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/main/java/org/jfree/chart/demo/selection/SelectionDemo8.java | /* -------------------
* SelectionDemo1.java
* -------------------
* (C) Copyright 2009-2013, by Object Refinery Limited.
*
*/
package org.jfree.chart.demo.selection;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.panel.selectionhandler.EntitySelectionManager;
import org.jfree.chart.panel.selectionhandler.MouseClickSelectionHandler;
import org.jfree.chart.panel.selectionhandler.RectangularHeightRegionSelectionHandler;
import org.jfree.chart.panel.selectionhandler.RegionSelectionHandler;
import org.jfree.chart.plot.XYPlot;
import org.jfree.chart.renderer.item.IRSUtilities;
import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer;
import org.jfree.chart.ui.ApplicationFrame;
import org.jfree.chart.ui.NumberCellRenderer;
import org.jfree.chart.ui.RefineryUtilities;
import org.jfree.data.extension.DatasetIterator;
import org.jfree.data.extension.DatasetSelectionExtension;
import org.jfree.data.extension.impl.DatasetExtensionManager;
import org.jfree.data.extension.impl.XYCursor;
import org.jfree.data.extension.impl.XYDatasetSelectionExtension;
import org.jfree.data.general.Dataset;
import org.jfree.data.general.SelectionChangeEvent;
import org.jfree.data.general.SelectionChangeListener;
import org.jfree.data.time.Month;
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 javax.swing.*;
import javax.swing.border.EmptyBorder;
import javax.swing.border.TitledBorder;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableColumnModel;
import java.awt.*;
public class SelectionDemo8 extends ApplicationFrame implements
SelectionChangeListener<XYCursor> {
private JTable table;
private DefaultTableModel model;
private TimeSeriesCollection dataset;
/**
* A demonstration application showing how to create a simple time series
* chart. This example uses monthly data.
*
* @param title the frame title.
*/
public SelectionDemo8(String title) {
super(title);
ChartPanel chartPanel = (ChartPanel) createDemoPanel();
chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
chartPanel.setRangeZoomable(false);
JFreeChart chart = chartPanel.getChart();
XYPlot plot = (XYPlot) chart.getPlot();
this.dataset = (TimeSeriesCollection) plot.getDataset();
JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
split.add(chartPanel);
this.model = new DefaultTableModel(new String[] { "Series:", "Item:",
"Period:", "Value:" }, 0);
this.table = new JTable(this.model);
TableColumnModel tcm = this.table.getColumnModel();
tcm.getColumn(3).setCellRenderer(new NumberCellRenderer());
JPanel p = new JPanel(new BorderLayout());
JScrollPane scroller = new JScrollPane(this.table);
p.add(scroller);
p.setBorder(BorderFactory.createCompoundBorder(new TitledBorder(
"Selected Items: "), new EmptyBorder(4, 4, 4, 4)));
split.add(p);
setContentPane(split);
}
/**
* The selection changed, so we change the table model
*
* @param event
*/
public void selectionChanged(SelectionChangeEvent<XYCursor> event) {
while (this.model.getRowCount() > 0) {
this.model.removeRow(0);
}
XYDatasetSelectionExtension ext = (XYDatasetSelectionExtension)
event.getSelectionExtension();
DatasetIterator<XYCursor> iter = ext.getSelectionIterator(true);
while (iter.hasNext()) {
XYCursor dc = iter.next();
Comparable seriesKey = this.dataset.getSeriesKey(dc.series);
RegularTimePeriod p = this.dataset.getSeries(dc.series)
.getTimePeriod(dc.item);
Number value = this.dataset.getY(dc.series, dc.item);
this.model.addRow(new Object[] { seriesKey, new Integer(dc.item),
p, value});
}
}
/**
* Creates a chart.
*
* @param dataset a dataset.
*
* @return A chart.
*/
private static JFreeChart createChart(XYDataset dataset,
DatasetSelectionExtension<XYCursor> ext) {
JFreeChart chart = ChartFactory.createTimeSeriesChart("Stock Prices",
"Date", "Price Per Unit", dataset);
XYPlot plot = (XYPlot) chart.getPlot();
plot.setDomainPannable(true);
plot.setRangePannable(true);
plot.setDomainCrosshairVisible(true);
plot.setRangeCrosshairVisible(true);
XYLineAndShapeRenderer r = (XYLineAndShapeRenderer) plot.getRenderer();
r.setBaseShapesVisible(true);
r.setBaseShapesFilled(true);
r.setUseFillPaint(true);
r.setSeriesFillPaint(0, r.lookupSeriesPaint(0));
r.setSeriesFillPaint(1, r.lookupSeriesPaint(1));
r.setDrawOutlines(true);
//add selection specific rendering
IRSUtilities.setSelectedItemFillPaint(r, ext, Color.white);
//register plot as selection change listener
ext.addChangeListener(plot);
return chart;
}
/**
* Creates a dataset, consisting of two series of monthly data.
*
* @return The dataset.
*/
private static TimeSeriesCollection createDataset() {
TimeSeries s1 = new TimeSeries("S1");
s1.add(new Month(1, 2009), 181.8);
s1.add(new Month(2, 2009), 167.3);
s1.add(new Month(3, 2009), 153.8);
s1.add(new Month(4, 2009), 167.6);
s1.add(new Month(5, 2009), 158.8);
s1.add(new Month(6, 2009), 148.3);
s1.add(new Month(7, 2009), 153.9);
s1.add(new Month(8, 2009), 142.7);
s1.add(new Month(9, 2009), 123.2);
s1.add(new Month(10, 2009), 131.8);
s1.add(new Month(11, 2009), 139.6);
s1.add(new Month(12, 2009), 142.9);
s1.add(new Month(1, 2010), 138.7);
s1.add(new Month(2, 2010), 137.3);
s1.add(new Month(3, 2010), 143.9);
s1.add(new Month(4, 2010), 139.8);
s1.add(new Month(5, 2010), 137.0);
s1.add(new Month(6, 2010), 132.8);
TimeSeries s2 = new TimeSeries("S2");
s2.add(new Month(1, 2009), 129.6);
s2.add(new Month(2, 2009), 123.2);
s2.add(new Month(3, 2009), 117.2);
s2.add(new Month(4, 2009), 124.1);
s2.add(new Month(5, 2009), 122.6);
s2.add(new Month(6, 2009), 119.2);
s2.add(new Month(7, 2009), 116.5);
s2.add(new Month(8, 2009), 112.7);
s2.add(new Month(9, 2009), 101.5);
s2.add(new Month(10, 2009), 106.1);
s2.add(new Month(11, 2009), 110.3);
s2.add(new Month(12, 2009), 111.7);
s2.add(new Month(1, 2010), 111.0);
s2.add(new Month(2, 2010), 109.6);
s2.add(new Month(3, 2010), 113.2);
s2.add(new Month(4, 2010), 111.6);
s2.add(new Month(5, 2010), 108.8);
s2.add(new Month(6, 2010), 101.6);
TimeSeriesCollection dataset = new TimeSeriesCollection();
dataset.addSeries(s1);
dataset.addSeries(s2);
return dataset;
}
public final JPanel createDemoPanel() {
XYDataset xydataset = createDataset();
//extend dataset and add selection change listener for the demo
DatasetSelectionExtension<XYCursor> datasetExtension
= new XYDatasetSelectionExtension(xydataset);
datasetExtension.addChangeListener(this);
//standard setup
JFreeChart chart = createChart(xydataset, datasetExtension);
ChartPanel panel = new ChartPanel(chart);
//panel.setMouseWheelEnabled(true);
// add a selection handler
RegionSelectionHandler selectionHandler = new RectangularHeightRegionSelectionHandler();
panel.addMouseHandler(selectionHandler);
panel.addMouseHandler(new MouseClickSelectionHandler());
panel.removeMouseHandler(panel.getZoomHandler());
// add a selection manager
DatasetExtensionManager dExManager = new DatasetExtensionManager();
dExManager.registerDatasetExtension(datasetExtension);
panel.setSelectionManager(new EntitySelectionManager(panel,
new Dataset[] { xydataset }, dExManager));
return panel;
}
/**
* Starting point for the demonstration application.
*
* @param args ignored.
*/
public static void main(String[] args) {
SelectionDemo8 demo = new SelectionDemo8("JFreeChart: SelectionDemo8");
demo.pack();
RefineryUtilities.centerFrameOnScreen(demo);
demo.setVisible(true);
}
}
| 8,883 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
SelectionDemo1.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/main/java/org/jfree/chart/demo/selection/SelectionDemo1.java | /* -------------------
* SelectionDemo1.java
* -------------------
* (C) Copyright 2009-2013, by Object Refinery Limited.
*
*/
package org.jfree.chart.demo.selection;
import java.awt.BorderLayout;
import java.awt.Color;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.JTable;
import javax.swing.border.EmptyBorder;
import javax.swing.border.TitledBorder;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableColumnModel;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.panel.selectionhandler.EntitySelectionManager;
import org.jfree.chart.panel.selectionhandler.FreeRegionSelectionHandler;
import org.jfree.chart.panel.selectionhandler.MouseClickSelectionHandler;
import org.jfree.chart.panel.selectionhandler.RegionSelectionHandler;
import org.jfree.chart.plot.XYPlot;
import org.jfree.chart.renderer.item.IRSUtilities;
import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer;
import org.jfree.chart.ui.ApplicationFrame;
import org.jfree.chart.ui.NumberCellRenderer;
import org.jfree.chart.ui.RefineryUtilities;
import org.jfree.data.extension.DatasetIterator;
import org.jfree.data.extension.DatasetSelectionExtension;
import org.jfree.data.extension.impl.DatasetExtensionManager;
import org.jfree.data.extension.impl.XYCursor;
import org.jfree.data.extension.impl.XYDatasetSelectionExtension;
import org.jfree.data.general.Dataset;
import org.jfree.data.general.SelectionChangeEvent;
import org.jfree.data.general.SelectionChangeListener;
import org.jfree.data.time.Month;
import org.jfree.data.time.RegularTimePeriod;
import org.jfree.data.time.TimeSeries;
import org.jfree.data.time.TimeSeriesCollection;
import org.jfree.data.xy.XYDataset;
public class SelectionDemo1 extends ApplicationFrame implements
SelectionChangeListener<XYCursor> {
private JTable table;
private DefaultTableModel model;
private TimeSeriesCollection dataset;
/**
* A demonstration application showing how to create a simple time series
* chart. This example uses monthly data.
*
* @param title the frame title.
*/
public SelectionDemo1(String title) {
super(title);
ChartPanel chartPanel = (ChartPanel) createDemoPanel();
chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
JFreeChart chart = chartPanel.getChart();
XYPlot plot = (XYPlot) chart.getPlot();
this.dataset = (TimeSeriesCollection) plot.getDataset();
JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
split.add(chartPanel);
this.model = new DefaultTableModel(new String[] { "Series:", "Item:",
"Period:", "Value:" }, 0);
this.table = new JTable(this.model);
TableColumnModel tcm = this.table.getColumnModel();
tcm.getColumn(3).setCellRenderer(new NumberCellRenderer());
JPanel p = new JPanel(new BorderLayout());
JScrollPane scroller = new JScrollPane(this.table);
p.add(scroller);
p.setBorder(BorderFactory.createCompoundBorder(new TitledBorder(
"Selected Items: "), new EmptyBorder(4, 4, 4, 4)));
split.add(p);
setContentPane(split);
}
/**
* The selection changed, so we change the table model
*
* @param event
*/
public void selectionChanged(SelectionChangeEvent<XYCursor> event) {
while (this.model.getRowCount() > 0) {
this.model.removeRow(0);
}
XYDatasetSelectionExtension ext = (XYDatasetSelectionExtension)
event.getSelectionExtension();
DatasetIterator<XYCursor> iter = ext.getSelectionIterator(true);
while (iter.hasNext()) {
XYCursor dc = iter.next();
Comparable seriesKey = this.dataset.getSeriesKey(dc.series);
RegularTimePeriod p = this.dataset.getSeries(dc.series)
.getTimePeriod(dc.item);
Number value = this.dataset.getY(dc.series, dc.item);
this.model.addRow(new Object[] { seriesKey, new Integer(dc.item),
p, value});
}
}
/**
* Creates a chart.
*
* @param dataset a dataset.
*
* @return A chart.
*/
private static JFreeChart createChart(XYDataset dataset,
DatasetSelectionExtension<XYCursor> ext) {
JFreeChart chart = ChartFactory.createTimeSeriesChart("Stock Prices",
"Date", "Price Per Unit", dataset);
XYPlot plot = (XYPlot) chart.getPlot();
plot.setDomainPannable(true);
plot.setRangePannable(true);
plot.setDomainCrosshairVisible(true);
plot.setRangeCrosshairVisible(true);
XYLineAndShapeRenderer r = (XYLineAndShapeRenderer) plot.getRenderer();
r.setBaseShapesVisible(true);
r.setBaseShapesFilled(true);
r.setUseFillPaint(true);
r.setSeriesFillPaint(0, r.lookupSeriesPaint(0));
r.setSeriesFillPaint(1, r.lookupSeriesPaint(1));
//add selection specific rendering
IRSUtilities.setSelectedItemFillPaint(r, ext, Color.white);
//register plot as selection change listener
ext.addChangeListener(plot);
return chart;
}
/**
* Creates a dataset, consisting of two series of monthly data.
*
* @return The dataset.
*/
private static TimeSeriesCollection createDataset() {
TimeSeries s1 = new TimeSeries("S1");
s1.add(new Month(1, 2009), 181.8);
s1.add(new Month(2, 2009), 167.3);
s1.add(new Month(3, 2009), 153.8);
s1.add(new Month(4, 2009), 167.6);
s1.add(new Month(5, 2009), 158.8);
s1.add(new Month(6, 2009), 148.3);
s1.add(new Month(7, 2009), 153.9);
s1.add(new Month(8, 2009), 142.7);
s1.add(new Month(9, 2009), 123.2);
s1.add(new Month(10, 2009), 131.8);
s1.add(new Month(11, 2009), 139.6);
s1.add(new Month(12, 2009), 142.9);
s1.add(new Month(1, 2010), 138.7);
s1.add(new Month(2, 2010), 137.3);
s1.add(new Month(3, 2010), 143.9);
s1.add(new Month(4, 2010), 139.8);
s1.add(new Month(5, 2010), 137.0);
s1.add(new Month(6, 2010), 132.8);
TimeSeries s2 = new TimeSeries("S2");
s2.add(new Month(1, 2009), 129.6);
s2.add(new Month(2, 2009), 123.2);
s2.add(new Month(3, 2009), 117.2);
s2.add(new Month(4, 2009), 124.1);
s2.add(new Month(5, 2009), 122.6);
s2.add(new Month(6, 2009), 119.2);
s2.add(new Month(7, 2009), 116.5);
s2.add(new Month(8, 2009), 112.7);
s2.add(new Month(9, 2009), 101.5);
s2.add(new Month(10, 2009), 106.1);
s2.add(new Month(11, 2009), 110.3);
s2.add(new Month(12, 2009), 111.7);
s2.add(new Month(1, 2010), 111.0);
s2.add(new Month(2, 2010), 109.6);
s2.add(new Month(3, 2010), 113.2);
s2.add(new Month(4, 2010), 111.6);
s2.add(new Month(5, 2010), 108.8);
s2.add(new Month(6, 2010), 101.6);
TimeSeriesCollection dataset = new TimeSeriesCollection();
dataset.addSeries(s1);
dataset.addSeries(s2);
return dataset;
}
public final JPanel createDemoPanel() {
XYDataset xydataset = createDataset();
//extend dataset and add selection change listener for the demo
DatasetSelectionExtension<XYCursor> datasetExtension
= new XYDatasetSelectionExtension(xydataset);
datasetExtension.addChangeListener(this);
//standard setup
JFreeChart chart = createChart(xydataset, datasetExtension);
ChartPanel panel = new ChartPanel(chart);
panel.setMouseWheelEnabled(true);
// add a selection handler
RegionSelectionHandler selectionHandler = new FreeRegionSelectionHandler();
panel.addMouseHandler(selectionHandler);
panel.addMouseHandler(new MouseClickSelectionHandler());
panel.removeMouseHandler(panel.getZoomHandler());
// add a selection manager
DatasetExtensionManager dExManager = new DatasetExtensionManager();
dExManager.registerDatasetExtension(datasetExtension);
panel.setSelectionManager(new EntitySelectionManager(panel,
new Dataset[] { xydataset }, dExManager));
return panel;
}
/**
* Starting point for the demonstration application.
*
* @param args ignored.
*/
public static void main(String[] args) {
SelectionDemo1 demo = new SelectionDemo1("JFreeChart: SelectionDemo1");
demo.pack();
RefineryUtilities.centerFrameOnScreen(demo);
demo.setVisible(true);
}
}
| 8,974 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
SelectionDemo2.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/main/java/org/jfree/chart/demo/selection/SelectionDemo2.java | /* -------------------
* SelectionDemo2.java
* -------------------
* (C) Copyright 2009, by Object Refinery Limited.
*
*/
package org.jfree.chart.demo.selection;
import java.awt.BasicStroke;
import java.awt.BorderLayout;
import java.awt.Color;
import java.util.Random;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.JTable;
import javax.swing.border.EmptyBorder;
import javax.swing.border.TitledBorder;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableColumnModel;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.panel.selectionhandler.CircularRegionSelectionHandler;
import org.jfree.chart.panel.selectionhandler.EntitySelectionManager;
import org.jfree.chart.panel.selectionhandler.MouseClickSelectionHandler;
import org.jfree.chart.panel.selectionhandler.RegionSelectionHandler;
import org.jfree.chart.plot.XYPlot;
import org.jfree.chart.renderer.item.IRSUtilities;
import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer;
import org.jfree.chart.ui.ApplicationFrame;
import org.jfree.chart.ui.NumberCellRenderer;
import org.jfree.chart.ui.RefineryUtilities;
import org.jfree.data.extension.DatasetIterator;
import org.jfree.data.extension.DatasetSelectionExtension;
import org.jfree.data.extension.impl.DatasetExtensionManager;
import org.jfree.data.extension.impl.XYCursor;
import org.jfree.data.extension.impl.XYDatasetSelectionExtension;
import org.jfree.data.general.Dataset;
import org.jfree.data.general.SelectionChangeEvent;
import org.jfree.data.general.SelectionChangeListener;
import org.jfree.data.xy.XYDataset;
import org.jfree.data.xy.XYSeries;
import org.jfree.data.xy.XYSeriesCollection;
/**
* A demo scatter plot.
*/
public class SelectionDemo2 extends ApplicationFrame
implements SelectionChangeListener<XYCursor> {
private JTable table;
private DefaultTableModel model;
private XYSeriesCollection dataset;
/**
* A demonstration application showing a scatter plot.
*
* @param title the frame title.
*/
public SelectionDemo2(String title) {
super(title);
ChartPanel chartPanel = (ChartPanel) createDemoPanel();
chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
JFreeChart chart = chartPanel.getChart();
XYPlot plot = (XYPlot) chart.getPlot();
this.dataset = (XYSeriesCollection) plot.getDataset();
JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
split.add(chartPanel);
this.model = new DefaultTableModel(new String[] {"Series:", "Item:", "X:", "Y:"}, 0);
this.table = new JTable(this.model);
TableColumnModel tcm = this.table.getColumnModel();
tcm.getColumn(2).setCellRenderer(new NumberCellRenderer());
tcm.getColumn(3).setCellRenderer(new NumberCellRenderer());
JPanel p = new JPanel(new BorderLayout());
JScrollPane scroller = new JScrollPane(this.table);
p.add(scroller);
p.setBorder(BorderFactory.createCompoundBorder(
new TitledBorder("Selected Items: "),
new EmptyBorder(4, 4, 4, 4)));
split.add(p);
setContentPane(split);
}
/**
* The selection changed, so we change the table model
*
* @param event
*/
public void selectionChanged(SelectionChangeEvent<XYCursor> event) {
while (this.model.getRowCount() > 0) {
this.model.removeRow(0);
}
XYDatasetSelectionExtension ext = (XYDatasetSelectionExtension)
event.getSelectionExtension();
DatasetIterator<XYCursor> iter = ext.getSelectionIterator(true);
while (iter.hasNext()) {
XYCursor dc = iter.next();
Comparable seriesKey = this.dataset.getSeriesKey(dc.series);
Number x = this.dataset.getX(dc.series, dc.item);
Number y = this.dataset.getX(dc.series, dc.item);
this.model.addRow(new Object[] { seriesKey, new Integer(dc.item),
x, y});
}
}
private static JFreeChart createChart(XYDataset dataset,
DatasetSelectionExtension<XYCursor> ext) {
JFreeChart chart = ChartFactory.createScatterPlot("SelectionDemo2",
"X", "Y", dataset);
XYPlot plot = (XYPlot) chart.getPlot();
plot.setNoDataMessage("NO DATA");
plot.setDomainPannable(true);
plot.setRangePannable(true);
plot.setDomainZeroBaselineVisible(true);
plot.setRangeZeroBaselineVisible(true);
plot.setDomainGridlineStroke(new BasicStroke(0.0f));
plot.setRangeGridlineStroke(new BasicStroke(0.0f));
plot.setDomainMinorGridlinesVisible(true);
plot.setRangeMinorGridlinesVisible(true);
XYLineAndShapeRenderer r = (XYLineAndShapeRenderer) plot.getRenderer();
r.setSeriesFillPaint(0, r.lookupSeriesPaint(0));
r.setSeriesFillPaint(1, r.lookupSeriesPaint(1));
r.setSeriesFillPaint(2, r.lookupSeriesPaint(2));
r.setUseFillPaint(true);
NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
domainAxis.setAutoRangeIncludesZero(false);
domainAxis.setTickMarkInsideLength(2.0f);
domainAxis.setTickMarkOutsideLength(2.0f);
domainAxis.setMinorTickCount(2);
domainAxis.setMinorTickMarksVisible(true);
NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
rangeAxis.setTickMarkInsideLength(2.0f);
rangeAxis.setTickMarkOutsideLength(2.0f);
rangeAxis.setMinorTickCount(2);
rangeAxis.setMinorTickMarksVisible(true);
//add selection specific rendering
IRSUtilities.setSelectedItemFillPaint(r, ext, Color.white);
//register plot as selection change listener
ext.addChangeListener(plot);
return chart;
}
public static XYDataset createDataset() {
Random rgen = new Random();
XYSeriesCollection dataset = new XYSeriesCollection();
for (int s = 0; s < 3; s++) {
XYSeries series = new XYSeries("S" + s);
for (int i = 0; i < 100; i++) {
double x = rgen.nextGaussian() * 200;
double y = rgen.nextGaussian() * 200;
series.add(x, y);
}
dataset.addSeries(series);
}
return dataset;
}
/**
* Creates a panel for the demo (used by SuperDemo.java).
*
* @return A panel.
*/
public JPanel createDemoPanel() {
XYDataset dataset = createDataset();
//extend dataset and add selection change listener for the demo
DatasetSelectionExtension<XYCursor> datasetExtension
= new XYDatasetSelectionExtension(dataset);
datasetExtension.addChangeListener(this);
//standard setup
JFreeChart chart = createChart(dataset, datasetExtension);
ChartPanel panel = new ChartPanel(chart);
panel.setMouseWheelEnabled(true);
// add a selection handler
RegionSelectionHandler selectionHandler
= new CircularRegionSelectionHandler();
panel.addMouseHandler(selectionHandler);
panel.addMouseHandler(new MouseClickSelectionHandler());
panel.removeMouseHandler(panel.getZoomHandler());
// add a selection manager
DatasetExtensionManager dExManager = new DatasetExtensionManager();
dExManager.registerDatasetExtension(datasetExtension);
panel.setSelectionManager(new EntitySelectionManager(panel,
new Dataset[] { dataset }, dExManager));
return panel;
}
/**
* Starting point for the demonstration application.
*
* @param args ignored.
*/
public static void main(String[] args) {
SelectionDemo2 demo = new SelectionDemo2(
"JFreeChart: SelectionDemo2.java");
demo.pack();
RefineryUtilities.centerFrameOnScreen(demo);
demo.setVisible(true);
}
}
| 8,279 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
SelectionDemo9.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/main/java/org/jfree/chart/demo/selection/SelectionDemo9.java | /* -------------------
* SelectionDemo1.java
* -------------------
* (C) Copyright 2009-2013, by Object Refinery Limited.
*
*/
package org.jfree.chart.demo.selection;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.DateAxis;
import org.jfree.chart.block.BlockContainer;
import org.jfree.chart.demo.selection.stacked.CategoryTableXYDatasetRTV;
import org.jfree.chart.panel.selectionhandler.EntitySelectionManager;
import org.jfree.chart.panel.selectionhandler.MouseClickSelectionHandler;
import org.jfree.chart.panel.selectionhandler.RectangularHeightRegionSelectionHandler;
import org.jfree.chart.panel.selectionhandler.RegionSelectionHandler;
import org.jfree.chart.plot.Marker;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.plot.XYPlot;
import org.jfree.chart.renderer.item.IRSUtilities;
import org.jfree.chart.renderer.xy.StackedXYAreaRenderer3;
import org.jfree.chart.title.LegendTitle;
import org.jfree.chart.ui.ApplicationFrame;
import org.jfree.chart.ui.NumberCellRenderer;
import org.jfree.chart.ui.RefineryUtilities;
import org.jfree.data.extension.DatasetIterator;
import org.jfree.data.extension.DatasetSelectionExtension;
import org.jfree.data.extension.impl.DatasetExtensionManager;
import org.jfree.data.extension.impl.XYCursor;
import org.jfree.data.extension.impl.XYDatasetSelectionExtension;
import org.jfree.data.general.Dataset;
import org.jfree.data.general.SelectionChangeEvent;
import org.jfree.data.general.SelectionChangeListener;
import org.jfree.data.xy.CategoryTableXYDataset;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
import javax.swing.border.TitledBorder;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableColumnModel;
import java.awt.*;
public class SelectionDemo9 extends ApplicationFrame implements
SelectionChangeListener<XYCursor> {
private JTable table;
private DefaultTableModel model;
//private TimeSeriesCollection dataset;
// Components (ChartPanel)
private ChartPanel chartPanel;
private JFreeChart chart;
private XYPlot plot;
private StackedXYAreaRenderer3 renderer;
private CategoryTableXYDataset dataset;
private DateAxis xAxis;
private String dateTimeAxisLabel;
private LegendTitle legend;
private BlockContainer blockContWrapper;
private BlockContainer itemss;
private Marker currentMarker;
/**
* A demonstration application showing how to create a simple time series
* chart. This example uses monthly data.
*
* @param title the frame title.
*/
public SelectionDemo9(String title) {
super(title);
ChartPanel chartPanel = (ChartPanel) createDemoPanel();
chartPanel.setPreferredSize(new Dimension(500, 270));
chartPanel.setRangeZoomable(false);
JFreeChart chart = chartPanel.getChart();
XYPlot plot = (XYPlot) chart.getPlot();
this.dataset = new CategoryTableXYDataset();
JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
split.add(chartPanel);
this.model = new DefaultTableModel(new String[] { "Series:", "Item:",
"Period:", "Value:" }, 0);
this.table = new JTable(this.model);
TableColumnModel tcm = this.table.getColumnModel();
tcm.getColumn(3).setCellRenderer(new NumberCellRenderer());
JPanel p = new JPanel(new BorderLayout());
JScrollPane scroller = new JScrollPane(this.table);
p.add(scroller);
p.setBorder(BorderFactory.createCompoundBorder(new TitledBorder(
"Selected Items: "), new EmptyBorder(4, 4, 4, 4)));
split.add(p);
setContentPane(split);
}
/**
* The selection changed, so we change the table model
*
* @param event
*/
public void selectionChanged(SelectionChangeEvent<XYCursor> event) {
while (this.model.getRowCount() > 0) {
this.model.removeRow(0);
}
XYDatasetSelectionExtension ext = (XYDatasetSelectionExtension)
event.getSelectionExtension();
DatasetIterator<XYCursor> iter = ext.getSelectionIterator(true);
while (iter.hasNext()) {
XYCursor dc = iter.next();
Comparable seriesKey = this.dataset.getSeriesKey(dc.series);
//RegularTimePeriod p = this.dataset.getSeries(dc.series).getTimePeriod(dc.item);
Number value = this.dataset.getY(dc.series, dc.item);
this.model.addRow(new Object[] { seriesKey, new Integer(dc.item),
dc.series, value});
System.out.println(dc.series+"--"+dc.item);
}
}
/**
* Creates a chart.
*
* @param dataset a dataset.
*
* @return A chart.
*/
private static JFreeChart createChart(CategoryTableXYDatasetRTV dataset,
DatasetSelectionExtension<XYCursor> ext) {
/*ChartFactory.createTimeSeriesChart("Stock Prices",
"Date", "Price Per Unit", dataset);*/
JFreeChart chart = ChartFactory.createStackedXYAreaChart(
"asflkasf;lkjasdljf", // chart title
"Кол-во", // range axis label
createDataset(), // data
PlotOrientation.VERTICAL, // the plot orientation
new DateAxis("time"), // the axis
false, // legend
true, // tooltips
false // urls
);
XYPlot plot = (XYPlot) chart.getPlot();
plot.setDomainPannable(true);
plot.setRangePannable(true);
plot.setDomainCrosshairVisible(true);
plot.setRangeCrosshairVisible(true);
StackedXYAreaRenderer3 r = (StackedXYAreaRenderer3) plot.getRenderer();
//r.setBaseShapesVisible(true);
//r.setBaseShapesFilled(true);
//r.setUseFillPaint(true);
r.setSeriesFillPaint(0, r.lookupSeriesPaint(0));
r.setSeriesFillPaint(1, r.lookupSeriesPaint(1));
//r.setDrawOutlines(true);
//add selection specific rendering
IRSUtilities.setSelectedItemFillPaint(r, ext, Color.black);
//register plot as selection change listener
ext.addChangeListener(plot);
return chart;
}
/**
* Creates a dataset, consisting of two series of monthly data.
*
* @return The dataset.
*/
private static CategoryTableXYDatasetRTV createDataset() {
CategoryTableXYDatasetRTV out = new CategoryTableXYDatasetRTV();
for (int i = 0; i < 100; i++) {
out.add(i,i*0.1,"test1");
}
for (int i = 0; i < 100; i++) {
out.add(i,i*0.1,"test2");
}
return out;
}
public final JPanel createDemoPanel() {
CategoryTableXYDatasetRTV xydataset = createDataset();
//extend dataset and add selection change listener for the demo
DatasetSelectionExtension<XYCursor> datasetExtension
= new XYDatasetSelectionExtension(xydataset);
datasetExtension.addChangeListener(this);
//standard setup
JFreeChart chart = createChart(xydataset, datasetExtension);
ChartPanel panel = new ChartPanel(chart);
panel.setMouseWheelEnabled(true);
// add a selection handler
RegionSelectionHandler selectionHandler = new RectangularHeightRegionSelectionHandler();
panel.addMouseHandler(selectionHandler);
panel.addMouseHandler(new MouseClickSelectionHandler());
panel.removeMouseHandler(panel.getZoomHandler());
// add a selection manager
DatasetExtensionManager dExManager = new DatasetExtensionManager();
dExManager.registerDatasetExtension(datasetExtension);
panel.setSelectionManager(new EntitySelectionManager(panel,
new Dataset[] { xydataset }, dExManager));
return panel;
}
/**
* Starting point for the demonstration application.
*
* @param args ignored.
*/
public static void main(String[] args) {
SelectionDemo9 demo = new SelectionDemo9("JFreeChart: SelectionDemo9");
demo.pack();
RefineryUtilities.centerFrameOnScreen(demo);
demo.setVisible(true);
}
}
| 8,532 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
SelectionDemo6Pie.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/main/java/org/jfree/chart/demo/selection/SelectionDemo6Pie.java | /* -------------------
* SelectionDemo6.java
* -------------------
* (C) Copyright 2013, by Object Refinery Limited.
*
*/
package org.jfree.chart.demo.selection;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.event.InputEvent;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.JTable;
import javax.swing.border.EmptyBorder;
import javax.swing.border.TitledBorder;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableColumnModel;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.labels.StandardPieSectionLabelGenerator;
import org.jfree.chart.panel.AbstractMouseHandler;
import org.jfree.chart.panel.selectionhandler.EntitySelectionManager;
import org.jfree.chart.panel.selectionhandler.FreeRegionSelectionHandler;
import org.jfree.chart.panel.selectionhandler.MouseClickSelectionHandler;
import org.jfree.chart.panel.selectionhandler.RegionSelectionHandler;
import org.jfree.chart.plot.PiePlot;
import org.jfree.chart.ui.ApplicationFrame;
import org.jfree.chart.ui.RefineryUtilities;
import org.jfree.data.extension.DatasetIterator;
import org.jfree.data.extension.DatasetSelectionExtension;
import org.jfree.data.extension.impl.DatasetExtensionManager;
import org.jfree.data.extension.impl.PieCursor;
import org.jfree.data.extension.impl.PieDatasetSelectionExtension;
import org.jfree.data.general.Dataset;
import org.jfree.data.general.DefaultPieDataset;
import org.jfree.data.general.PieDataset;
import org.jfree.data.general.SelectionChangeEvent;
import org.jfree.data.general.SelectionChangeListener;
/*
* based on PieChartDemo2
*/
public class SelectionDemo6Pie extends ApplicationFrame
implements SelectionChangeListener<PieCursor<String>> {
private JTable table;
private DefaultTableModel model;
private PieDataset dataset;
public SelectionDemo6Pie(String title) {
super(title);
JPanel chartPanel = createDemoPanel();
chartPanel.setPreferredSize(new java.awt.Dimension(700, 500));
JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
split.add(chartPanel);
this.model = new DefaultTableModel(new String[] { "section", "value:"},
0);
this.table = new JTable(this.model);
TableColumnModel tcm = this.table.getColumnModel();
JPanel p = new JPanel(new BorderLayout());
JScrollPane scroller = new JScrollPane(this.table);
p.add(scroller);
p.setBorder(BorderFactory.createCompoundBorder(new TitledBorder(
"Selected Items: "), new EmptyBorder(4, 4, 4, 4)));
split.add(p);
setContentPane(split);
}
private static PieDataset createDataset() {
DefaultPieDataset dataset = new DefaultPieDataset();
dataset.setValue("One", 43.2);
dataset.setValue("Two", 10.0);
dataset.setValue("Three", 27.5);
dataset.setValue("Four", 17.5);
dataset.setValue("Five", 11.0);
dataset.setValue("Six", 19.4);
return dataset;
}
private static JFreeChart createChart(final PieDataset dataset, DatasetSelectionExtension<PieCursor<String>> ext) {
JFreeChart chart = ChartFactory.createPieChart("Pie Chart Demo 2",
dataset);
final PiePlot plot = (PiePlot) chart.getPlot();
plot.setSectionPaint("One", new Color(160, 160, 255));
plot.setSectionPaint("Two", new Color(128, 128, 255 - 32));
plot.setSectionPaint("Three", new Color(96, 96, 255 - 64));
plot.setSectionPaint("Four", new Color(64, 64, 255 - 96));
plot.setSectionPaint("Five", new Color(32, 32, 255 - 128));
plot.setSectionPaint("Six", new Color(0, 0, 255 - 144));
plot.setNoDataMessage("No data available");
plot.setLabelGenerator(new StandardPieSectionLabelGenerator(
"{0} ({2} percent)"));
plot.setLabelBackgroundPaint(new Color(220, 220, 220));
plot.setLegendLabelToolTipGenerator(new StandardPieSectionLabelGenerator(
"Tooltip for legend item {0}"));
plot.setSimpleLabels(true);
plot.setInteriorGap(0.1);
//pie plots done use abstract renderers need to react to selection on our own
final PieCursor<String> cursor = new PieCursor<String>();
ext.addChangeListener(new SelectionChangeListener<PieCursor<String>>() {
public void selectionChanged(SelectionChangeEvent<PieCursor<String>> event) {
for (int i = 0; i < dataset.getItemCount(); i++) {
cursor.setPosition((String)dataset.getKey(i));
if (event.getSelectionExtension().isSelected(cursor)) {
plot.setExplodePercent(cursor.key, 0.15);
} else {
plot.setExplodePercent(cursor.key, 0.0);
}
}
}
});
return chart;
}
public final JPanel createDemoPanel() {
this.dataset = createDataset();
//extend dataset and add selection change listener for the demo
DatasetSelectionExtension<PieCursor<String>> datasetExtension
= new PieDatasetSelectionExtension<String>(this.dataset);
datasetExtension.addChangeListener(this);
//standard setup
JFreeChart chart = createChart(this.dataset, datasetExtension);
ChartPanel panel = new ChartPanel(chart);
panel.setMouseWheelEnabled(true);
//add a selection handler with shift modifier for clicking
RegionSelectionHandler selectionHandler
= new FreeRegionSelectionHandler();
AbstractMouseHandler clickHandler = new MouseClickSelectionHandler(
InputEvent.SHIFT_MASK);
panel.addMouseHandler(selectionHandler);
panel.addMouseHandler(clickHandler);
panel.removeMouseHandler(panel.getZoomHandler());
// add a selection manager
DatasetExtensionManager dExManager = new DatasetExtensionManager();
dExManager.registerDatasetExtension(datasetExtension);
panel.setSelectionManager(new EntitySelectionManager(panel,
new Dataset[] { dataset }, dExManager));
return panel;
}
public void selectionChanged(SelectionChangeEvent<PieCursor<String>>
event) {
while (this.model.getRowCount() > 0) {
this.model.removeRow(0);
}
PieDatasetSelectionExtension<String> ext
= (PieDatasetSelectionExtension<String>)
event.getSelectionExtension();
DatasetIterator<PieCursor<String>> iter = ext.getSelectionIterator(
true);
while (iter.hasNext()) {
PieCursor<String> dc = iter.next();
this.model.addRow(new Object[] {dc.key, this.dataset.getValue(
dc.key)});
}
}
public static void main(String[] args) {
SelectionDemo6Pie demo = new SelectionDemo6Pie(
"JFreeChart: SelectionDemo6Pie.java");
demo.pack();
RefineryUtilities.centerFrameOnScreen(demo);
demo.setVisible(true);
}
}
| 7,429 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
SelectionDemo3.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/main/java/org/jfree/chart/demo/selection/SelectionDemo3.java | /* -------------------
* SelectionDemo3.java
* -------------------
* (C) Copyright 2009, by Object Refinery Limited.
*
*/
package org.jfree.chart.demo.selection;
import java.awt.BasicStroke;
import java.awt.BorderLayout;
import java.awt.Color;
import java.util.Random;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.JTable;
import javax.swing.border.EmptyBorder;
import javax.swing.border.TitledBorder;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableColumnModel;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.panel.selectionhandler.EntitySelectionManager;
import org.jfree.chart.panel.selectionhandler.MouseClickSelectionHandler;
import org.jfree.chart.panel.selectionhandler.RectangularRegionSelectionHandler;
import org.jfree.chart.panel.selectionhandler.RegionSelectionHandler;
import org.jfree.chart.plot.XYPlot;
import org.jfree.chart.renderer.item.IRSUtilities;
import org.jfree.chart.renderer.xy.XYDotRenderer;
import org.jfree.chart.ui.ApplicationFrame;
import org.jfree.chart.ui.NumberCellRenderer;
import org.jfree.chart.ui.RefineryUtilities;
import org.jfree.data.extension.DatasetIterator;
import org.jfree.data.extension.DatasetSelectionExtension;
import org.jfree.data.extension.impl.DatasetExtensionManager;
import org.jfree.data.extension.impl.XYCursor;
import org.jfree.data.extension.impl.XYDatasetSelectionExtension;
import org.jfree.data.general.Dataset;
import org.jfree.data.general.SelectionChangeEvent;
import org.jfree.data.general.SelectionChangeListener;
import org.jfree.data.xy.XYDataset;
import org.jfree.data.xy.XYSeries;
import org.jfree.data.xy.XYSeriesCollection;
/**
* A demo scatter plot.
*/
public class SelectionDemo3 extends ApplicationFrame
implements SelectionChangeListener<XYCursor> {
private JTable table;
private DefaultTableModel model;
private XYSeriesCollection dataset;
/**
* A demonstration application showing a scatter plot.
*
* @param title the frame title.
*/
public SelectionDemo3(String title) {
super(title);
ChartPanel chartPanel = (ChartPanel) createDemoPanel();
chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
JFreeChart chart = chartPanel.getChart();
XYPlot plot = (XYPlot) chart.getPlot();
this.dataset = (XYSeriesCollection) plot.getDataset();
JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
split.add(chartPanel);
this.model = new DefaultTableModel(new String[] {"Series:", "Item:",
"X:", "Y:"}, 0);
this.table = new JTable(this.model);
TableColumnModel tcm = this.table.getColumnModel();
tcm.getColumn(2).setCellRenderer(new NumberCellRenderer());
tcm.getColumn(3).setCellRenderer(new NumberCellRenderer());
JPanel p = new JPanel(new BorderLayout());
JScrollPane scroller = new JScrollPane(this.table);
p.add(scroller);
p.setBorder(BorderFactory.createCompoundBorder(
new TitledBorder("Selected Items: "),
new EmptyBorder(4, 4, 4, 4)));
split.add(p);
setContentPane(split);
}
private static JFreeChart createChart(XYDataset dataset,
DatasetSelectionExtension<XYCursor> ext) {
JFreeChart chart = ChartFactory.createScatterPlot("SelectionDemo3",
"X", "Y", dataset);
XYPlot plot = (XYPlot) chart.getPlot();
plot.setNoDataMessage("NO DATA");
plot.setDomainPannable(true);
plot.setRangePannable(true);
plot.setDomainZeroBaselineVisible(true);
plot.setRangeZeroBaselineVisible(true);
plot.setDomainGridlineStroke(new BasicStroke(0.0f));
plot.setRangeGridlineStroke(new BasicStroke(0.0f));
plot.setDomainMinorGridlinesVisible(true);
plot.setRangeMinorGridlinesVisible(true);
//XYItemRenderer r = plot.getRenderer();
XYDotRenderer r = new XYDotRenderer();
r.setDotHeight(2);
r.setDotWidth(2);
r.setSeriesPaint(0, Color.blue);
r.setSeriesPaint(1, Color.green);
r.setSeriesPaint(2, Color.yellow);
r.setSeriesPaint(3, Color.orange);
plot.setRenderer(r);
NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
domainAxis.setAutoRangeIncludesZero(false);
domainAxis.setTickMarkInsideLength(2.0f);
domainAxis.setTickMarkOutsideLength(2.0f);
domainAxis.setMinorTickCount(2);
domainAxis.setMinorTickMarksVisible(true);
NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
rangeAxis.setTickMarkInsideLength(2.0f);
rangeAxis.setTickMarkOutsideLength(2.0f);
rangeAxis.setMinorTickCount(2);
rangeAxis.setMinorTickMarksVisible(true);
//add selection specific rendering
IRSUtilities.setSelectedItemPaint(r, ext, Color.red);
//register plot as selection change listener
ext.addChangeListener(plot);
return chart;
}
/**
* The selection changed, so we change the table model
*
* @param event
*/
public void selectionChanged(SelectionChangeEvent<XYCursor> event) {
while (this.model.getRowCount() > 0) {
this.model.removeRow(0);
}
XYDatasetSelectionExtension ext = (XYDatasetSelectionExtension)
event.getSelectionExtension();
DatasetIterator<XYCursor> iter = ext.getSelectionIterator(true);
while (iter.hasNext()) {
XYCursor dc = iter.next();
Comparable seriesKey = this.dataset.getSeriesKey(dc.series);
Number x = this.dataset.getX(dc.series, dc.item);
Number y = this.dataset.getX(dc.series, dc.item);
this.model.addRow(new Object[] { seriesKey, new Integer(dc.item),
x, y});
}
}
public static XYDataset createDataset() {
String[] names = {"JFreeChart", "Eastwood", "Orson", "JCommon"};
Random rgen = new Random();
XYSeriesCollection dataset = new XYSeriesCollection();
for (int s = 0; s < 4; s++) {
XYSeries series = new XYSeries(names[s]);
for (int i = 0; i < 5000; i++) {
double x = rgen.nextGaussian() * 200;
double y = rgen.nextGaussian() * 200;
series.add(x, y);
}
dataset.addSeries(series);
}
return dataset;
}
/**
* Creates a panel for the demo (used by SuperDemo.java).
*
* @return A panel.
*/
public final JPanel createDemoPanel() {
XYDataset xydataset = createDataset();
//extend dataset and add selection change listener for the demo
DatasetSelectionExtension<XYCursor> datasetExtension
= new XYDatasetSelectionExtension(xydataset);
datasetExtension.addChangeListener(this);
//standard setup
JFreeChart chart = createChart(xydataset, datasetExtension);
ChartPanel panel = new ChartPanel(chart);
panel.setMouseWheelEnabled(true);
// add a selection handler
RegionSelectionHandler selectionHandler
= new RectangularRegionSelectionHandler();
panel.addMouseHandler(selectionHandler);
panel.addMouseHandler(new MouseClickSelectionHandler());
panel.removeMouseHandler(panel.getZoomHandler());
// add a selection manager
DatasetExtensionManager dExManager = new DatasetExtensionManager();
dExManager.registerDatasetExtension(datasetExtension);
panel.setSelectionManager(new EntitySelectionManager(panel,
new Dataset[] { xydataset }, dExManager));
return panel;
}
/**
* Starting point for the demonstration application.
*
* @param args ignored.
*/
public static void main(String[] args) {
SelectionDemo3 demo = new SelectionDemo3(
"JFreeChart: SelectionDemo3.java");
demo.pack();
RefineryUtilities.centerFrameOnScreen(demo);
demo.setVisible(true);
}
}
| 8,423 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
CategoryTableXYDatasetRTV.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/main/java/org/jfree/chart/demo/selection/stacked/CategoryTableXYDatasetRTV.java | package org.jfree.chart.demo.selection.stacked;
import org.jfree.data.xy.CategoryTableXYDataset;
public class CategoryTableXYDatasetRTV extends CategoryTableXYDataset {
public CategoryTableXYDatasetRTV() {
}
}
| 220 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
StackedChartPanel.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/main/java/org/jfree/chart/demo/selection/stacked/StackedChartPanel.java | package org.jfree.chart.demo.selection.stacked;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.DateAxis;
import org.jfree.chart.axis.PeriodAxis;
import org.jfree.chart.axis.PeriodAxisLabelInfo;
import org.jfree.chart.block.BlockBorder;
import org.jfree.chart.block.BlockContainer;
import org.jfree.chart.block.BorderArrangement;
import org.jfree.chart.labels.StandardXYToolTipGenerator;
import org.jfree.chart.labels.XYItemLabelGenerator;
import org.jfree.chart.plot.Marker;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.plot.XYPlot;
import org.jfree.chart.renderer.xy.StackedXYAreaRenderer3;
import org.jfree.chart.title.LegendTitle;
import org.jfree.chart.ui.HorizontalAlignment;
import org.jfree.chart.ui.RectangleEdge;
import org.jfree.chart.ui.RectangleInsets;
import org.jfree.data.time.Quarter;
import org.jfree.data.time.Year;
import java.awt.*;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.TimeZone;
public class StackedChartPanel {
private ChartPanel chartPanel;
private JFreeChart jFreeChart;
private XYPlot xyPlot;
private StackedXYAreaRenderer3 stackedXYAreaRenderer3;
private CategoryTableXYDatasetRTV dataset;
private DateAxis dateAxis;
private String dateTimeAxisLabel;
private BlockContainer blockContainerParent;
private BlockContainer legendItemContainer;
private LegendTitle legendTitle;
private Marker currentMarker;
public StackedChartPanel(){}
public void chartInitialize(){
this.setDateAxis(new DateAxis("time"));
this.setDateTimeAxisLabel("label here");
this.setJFreeChart();
this.setXyPlot((XYPlot) this.getjFreeChart().getPlot());
this.setStackedXYAreaRenderer3();
((XYPlot) this.getjFreeChart().getPlot()).setRenderer(this.getStackedXYAreaRenderer3());
((XYPlot) this.getjFreeChart().getPlot()).getRangeAxis().setLowerBound(0.0);
((XYPlot) this.getjFreeChart().getPlot()).getRangeAxis().setAutoRange(true);
((XYPlot) this.getjFreeChart().getPlot()).setDomainAxes(getDomainPeriodAxis());
this.setLegendTitle();
this.getjFreeChart().addSubtitle(this.getLegendTitle());
this.setChartPanel(this.getjFreeChart());
this.getChartPanel().setRangeZoomable(false);
}
public void setDataset(CategoryTableXYDatasetRTV dataset){
this.dataset = dataset;
}
public void setSelectionChart(boolean flag){
this.chartPanel.setDomainZoomable(flag);
}
public ChartPanel getChartPanel() { return this.chartPanel; }
private void setChartPanel(JFreeChart jfree) {
this.chartPanel = new ChartPanel(jfree);
}
private CategoryTableXYDatasetRTV getDataset() {
return dataset;
}
private DateAxis getDateAxis() {
return dateAxis;
}
private void setDateAxis(DateAxis dateAxis) {
this.dateAxis = dateAxis;
}
private String getDateTimeAxisLabel() {
return dateTimeAxisLabel;
}
private void setDateTimeAxisLabel(String dateTimeAxisLabel) {
this.dateTimeAxisLabel = dateTimeAxisLabel;
}
private JFreeChart getjFreeChart() {
return jFreeChart;
}
private LegendTitle getLegendTitle() {
return legendTitle;
}
public void setChartTitle(String titleText){ this.jFreeChart.setTitle(titleText); }
private void setLegendTitle() {
this.legendTitle = new LegendTitle(this.jFreeChart.getPlot());
this.blockContainerParent = new BlockContainer(new BorderArrangement());
this.blockContainerParent.setFrame(new BlockBorder(1.0, 1.0, 1.0, 1.0));
this.legendItemContainer = this.legendTitle.getItemContainer();
this.legendItemContainer.setPadding(2, 10, 5, 2);
this.blockContainerParent.add(this.legendItemContainer);
this.legendTitle.setWrapper(this.blockContainerParent);
this.legendTitle.setPosition(RectangleEdge.RIGHT);
this.legendTitle.setHorizontalAlignment(HorizontalAlignment.LEFT);
}
private void setJFreeChart() {
this.jFreeChart = ChartFactory.createStackedXYAreaChart(
"", // chart title
"X Value", // domain axis label
"Кол-во", // range axis label
this.getDataset(), // data
PlotOrientation.VERTICAL, // the plot orientation
this.getDateAxis(), // the axis
false, // legend
true, // tooltips
false // urls
);
}
private XYPlot getXyPlot() {
return xyPlot;
}
private void setXyPlot(XYPlot xyPlot) {
this.xyPlot = xyPlot;
}
private StackedXYAreaRenderer3 getStackedXYAreaRenderer3() {
return stackedXYAreaRenderer3;
}
private void setStackedXYAreaRenderer3() {
this.stackedXYAreaRenderer3 = new StackedXYAreaRenderer3();
this.stackedXYAreaRenderer3.setRoundXCoordinates(true);
this.stackedXYAreaRenderer3.setDefaultItemLabelGenerator (
(XYItemLabelGenerator)
new StandardXYToolTipGenerator("{0} ({1}, {2})",
new SimpleDateFormat("dd.MM.yyyy"),
new DecimalFormat("0.0")));
}
private PeriodAxis[] getDomainPeriodAxis(){
PeriodAxis domainAxis = new PeriodAxis("");
domainAxis.setTimeZone(TimeZone.getTimeZone("Asia/Yekaterinburg"));
domainAxis.setMajorTickTimePeriodClass(Quarter.class);
PeriodAxisLabelInfo[] info = new PeriodAxisLabelInfo[2];
info[0] = new PeriodAxisLabelInfo(Quarter.class,
new SimpleDateFormat("M"), new RectangleInsets(2, 2, 2, 2),
new Font("SansSerif", Font.BOLD, 8), Color.blue, false,
new BasicStroke(0.0f), Color.lightGray);
info[1] = new PeriodAxisLabelInfo(Year.class,
new SimpleDateFormat("yyyy"));
domainAxis.setLabelInfo(info);
PeriodAxis[] out = new PeriodAxis[1];
out[0] = domainAxis;
return out;
}
}
| 6,549 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
EncoderUtil.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/main/java/org/jfree/chart/encoders/EncoderUtil.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2011, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 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);
}
}
| 7,460 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
package-info.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/main/java/org/jfree/chart/encoders/package-info.java | /**
* Classes related to the encoding of charts to different image formats.
*/
package org.jfree.chart.encoders;
| 115 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
SunJPEGEncoderAdapter.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/main/java/org/jfree/chart/encoders/SunJPEGEncoderAdapter.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2011, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 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-2008, 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);
*
*/
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;
/**
* 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 <code>SunJPEGEncoderAdapter</code> 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 <code>false</code> always, indicating that this encoder does not
* encode alpha transparency.
*
* @return <code>false</code>.
*/
@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 (<code>null</code> not
* permitted).
*
* @return The byte[] that is the encoded image.
*
* @throws IOException if there is an I/O problem.
* @throws NullPointerException if <code>bufferedImage</code> is
* <code>null</code>.
*/
@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 (<code>null</code> not
* permitted).
* @param outputStream the OutputStream to write the encoded image to
* (<code>null</code> not permitted).
*
* @throws IOException if there is an I/O problem.
* @throws NullPointerException if <code>bufferedImage</code> is
* <code>null</code>.
*/
@Override
public void encode(BufferedImage bufferedImage, OutputStream outputStream)
throws IOException {
if (bufferedImage == null) {
throw new IllegalArgumentException("Null 'image' argument.");
}
if (outputStream == null) {
throw new IllegalArgumentException("Null 'outputStream' argument.");
}
Iterator<ImageWriter> iterator = ImageIO.getImageWritersByFormatName("jpeg");
ImageWriter writer = 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();
}
}
| 6,359 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
ImageEncoderFactory.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/main/java/org/jfree/chart/encoders/ImageEncoderFactory.java | /* ===========================================================
* 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.]
*
* ------------------------
* 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);
*
*/
package org.jfree.chart.encoders;
import java.util.HashMap;
/**
* Factory class for returning {@link ImageEncoder}s for different
* {@link ImageFormat}s.
*/
public class ImageEncoderFactory {
/** Storage for the encoders. */
private static HashMap<String, String> 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<String, String>();
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 <code>null</code> if none available.
*/
public static ImageEncoder newInstance(String format) {
ImageEncoder imageEncoder = null;
String className = 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 <code>null</code> 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 <code>null</code> 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 <code>null</code> 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;
}
}
| 5,503 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
ImageFormat.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/main/java/org/jfree/chart/encoders/ImageFormat.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2011, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 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";
}
| 1,999 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
ImageEncoder.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/main/java/org/jfree/chart/encoders/ImageEncoder.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2011, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 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);
}
| 3,323 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
SunPNGEncoderAdapter.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/main/java/org/jfree/chart/encoders/SunPNGEncoderAdapter.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2011, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 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-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.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import javax.imageio.ImageIO;
/**
* 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 {
if (bufferedImage == null) {
throw new IllegalArgumentException("Null 'image' argument.");
}
if (outputStream == null) {
throw new IllegalArgumentException("Null 'outputStream' argument.");
}
ImageIO.write(bufferedImage, ImageFormat.PNG, outputStream);
}
}
| 4,284 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
ChartEditorFactory.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/main/java/org/jfree/chart/editor/ChartEditorFactory.java | /* ===========================================================
* 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.]
*
* -----------------------
* 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);
}
| 1,893 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
DefaultValueAxisEditor.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/main/java/org/jfree/chart/editor/DefaultValueAxisEditor.java | /* ===========================================================
* 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.]
*
* ----------------------
* DefaultValueAxisEditor.java
* ----------------------
* (C) Copyright 2005-2012, 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);
* 17-Jun-2012 : Removed JCommon dependencies (DG);
*
*/
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.ui.LCBLayout;
import org.jfree.chart.ui.PaintSample;
import org.jfree.chart.ui.StrokeChooserPanel;
import org.jfree.chart.ui.StrokeSample;
import org.jfree.chart.util.ResourceBundleWrapper;
/**
* 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 <code>true</code> 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);
}
}
| 14,039 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
DefaultTitleEditor.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/main/java/org/jfree/chart/editor/DefaultTitleEditor.java | /* ===========================================================
* 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.]
*
* -----------------------
* DefaultTitleEditor.java
* -----------------------
* (C) Copyright 2005-2012, 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);
* 17-Jun-2012 : Removed JCommon dependencies (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.ui.FontChooserPanel;
import org.jfree.chart.ui.FontDisplayField;
import org.jfree.chart.ui.LCBLayout;
import org.jfree.chart.ui.PaintSample;
import org.jfree.chart.title.TextTitle;
import org.jfree.chart.title.Title;
import org.jfree.chart.util.ResourceBundleWrapper;
/**
* 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);
}
}
}
| 10,197 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
package-info.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/main/java/org/jfree/chart/editor/package-info.java | /**
* Provides a simple (but so far incomplete) framework for editing chart
* properties.
*/
package org.jfree.chart.editor;
| 128 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
DefaultNumberAxisEditor.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/main/java/org/jfree/chart/editor/DefaultNumberAxisEditor.java | /* ===========================================================
* 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.]
*
* ----------------------------
* 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.chart.ui.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));
}
}
}
| 6,046 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
ChartEditorManager.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/main/java/org/jfree/chart/editor/ChartEditorManager.java | /* ===========================================================
* 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.]
*
* -----------------------
* ChartEditorManager.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 org.jfree.chart.JFreeChart;
/**
* 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 <code>null</code>).
*/
public static ChartEditorFactory getChartEditorFactory() {
return factory;
}
/**
* Sets the chart editor factory.
*
* @param f the new factory (<code>null</code> not permitted).
*/
public static void setChartEditorFactory(ChartEditorFactory f) {
if (f == null) {
throw new IllegalArgumentException("Null 'f' argument.");
}
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);
}
}
| 3,005 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
DefaultChartEditorFactory.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/main/java/org/jfree/chart/editor/DefaultChartEditorFactory.java | /* ===========================================================
* 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.]
*
* ------------------------------
* 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);
}
}
| 2,150 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
DefaultPlotEditor.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/main/java/org/jfree/chart/editor/DefaultPlotEditor.java | /* ===========================================================
* 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.]
*
* ----------------------
* DefaultPlotEditor.java
* ----------------------
* (C) Copyright 2005-2012, 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);
* 15-Jun-2012 : Removed JCommon dependencies (DG);
*
*/
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.ui.LCBLayout;
import org.jfree.chart.ui.PaintSample;
import org.jfree.chart.ui.RectangleInsets;
import org.jfree.chart.ui.StrokeChooserPanel;
import org.jfree.chart.ui.StrokeSample;
import org.jfree.chart.plot.CategoryPlot;
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;
/**
* 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;
/** 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 <tt>CategoryPlot</tt>s and
* <tt>XYPlot</tt>s).
*/
private PlotOrientation plotOrientation;
/**
* The orientation combo box (for <tt>CategoryPlot</tt>s and
* <tt>XYPlot</tt>s).
*/
private JComboBox orientationCombo;
/** Whether or not to draw lines between each data point (for
* <tt>LineAndShapeRenderer</tt>s and <tt>StandardXYItemRenderer</tt>s).
*/
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
* <tt>LineAndShapeRenderer</tt>s and <tt>StandardXYItemRenderer</tt>s).
*/
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.
* <P>
* 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 = r.getBaseLinesVisible();
this.drawShapes = r.getBaseShapesVisible();
}
}
else if (plot instanceof XYPlot) {
XYItemRenderer renderer = ((XYPlot) plot).getRenderer();
if (renderer instanceof StandardXYItemRenderer) {
StandardXYItemRenderer r = (StandardXYItemRenderer) renderer;
this.drawLines = r.getPlotLines();
this.drawShapes = 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);
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);
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);
}
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 <code>null</code>).
*/
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
* <tt>CategoryPlot</tt> or a <tt>XYPlot</tt>.
*/
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 <tt>LineAndShapeRenderer</tt>s and
* <tt>StandardXYItemRenderer</tt>s.
*/
private void attemptDrawLinesSelection() {
this.drawLines = this.drawLinesCheckBox.isSelected();
}
/**
* Allow the user to modify whether or not shapes are drawn at data points
* by <tt>LineAndShapeRenderer</tt>s and <tt>StandardXYItemRenderer</tt>s.
*/
private void attemptDrawShapesSelection() {
this.drawShapes = 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).setBaseLinesVisible(
this.drawLines);
}
}
else if (plot instanceof XYPlot) {
XYPlot p = (XYPlot) plot;
XYItemRenderer r = p.getRenderer();
if (r instanceof StandardXYItemRenderer) {
((StandardXYItemRenderer) r).setPlotLines(
this.drawLines);
}
}
}
if (this.drawShapes != null) {
if (plot instanceof CategoryPlot) {
CategoryPlot p = (CategoryPlot) plot;
CategoryItemRenderer r = p.getRenderer();
if (r instanceof LineAndShapeRenderer) {
((LineAndShapeRenderer) r).setBaseShapesVisible(
this.drawShapes);
}
}
else if (plot instanceof XYPlot) {
XYPlot p = (XYPlot) plot;
XYItemRenderer r = p.getRenderer();
if (r instanceof StandardXYItemRenderer) {
((StandardXYItemRenderer) r).setBaseShapesVisible(
this.drawShapes);
}
}
}
}
}
| 22,928 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
DefaultPolarPlotEditor.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/main/java/org/jfree/chart/editor/DefaultPolarPlotEditor.java | /* ===========================================================
* 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.]
*
* ----------------------
* 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.chart.ui.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));
}
@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();
}
}
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));
}
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);
}
}
| 6,569 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
DefaultAxisEditor.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/main/java/org/jfree/chart/editor/DefaultAxisEditor.java | /* ===========================================================
* 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.]
*
* ----------------------
* DefaultAxisEditor.java
* ----------------------
* (C) Copyright 2005-2012, 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);
* 15-Jun-2012 : Remove JCommon dependencies (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.ui.FontChooserPanel;
import org.jfree.chart.ui.FontDisplayField;
import org.jfree.chart.ui.LCBLayout;
import org.jfree.chart.ui.PaintSample;
import org.jfree.chart.ui.RectangleInsets;
import org.jfree.chart.util.ResourceBundleWrapper;
/**
* 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 <code>null</code< if axis is <code>null</code>.
*/
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().toString());
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 <code>true</code> 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 <code>true</code> 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());
}
}
| 17,178 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
DefaultLogAxisEditor.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/main/java/org/jfree/chart/editor/DefaultLogAxisEditor.java | /* ===========================================================
* 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.]
*
* ----------------------
* DefaultLogAxisEditor.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 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));
}
@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();
}
}
@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);
LogAxis logAxis = (LogAxis) axis;
if (!isAutoTickUnitSelection()) {
logAxis.setTickUnit(new NumberTickUnit(manualTickUnitValue));
}
}
}
| 4,969 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
DefaultChartEditor.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/main/java/org/jfree/chart/editor/DefaultChartEditor.java | /* ===========================================================
* 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.]
*
* -----------------------
* DefaultChartEditor.java
* -----------------------
* (C) Copyright 2000-2012, 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.ui.LCBLayout;
import org.jfree.chart.ui.PaintSample;
import org.jfree.chart.plot.Plot;
import org.jfree.chart.plot.PolarPlot;
import org.jfree.chart.title.Title;
import org.jfree.chart.util.ResourceBundleWrapper;
/**
* 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 <code>true</code> 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());
}
}
| 9,602 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
ChartEditor.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/main/java/org/jfree/chart/editor/ChartEditor.java | /* ===========================================================
* 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.]
*
* ----------------
* 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);
}
| 1,976 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
package-info.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/main/java/org/jfree/chart/urls/package-info.java | /**
* Classes for adding URLS to charts for HTML image map generation.
*/
package org.jfree.chart.urls;
| 106 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
XYURLGenerator.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/main/java/org/jfree/chart/urls/XYURLGenerator.java | /* ===========================================================
* 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.]
*
* -------------------
* 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 (<code>null</code> not permitted).
* @param series the series index (zero-based).
* @param item the item index (zero-based).
*
* @return A string containing the generated URL (possibly
* <code>null</code>).
*/
public String generateURL(XYDataset dataset, int series, int item);
}
| 2,779 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
TimeSeriesURLGenerator.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/main/java/org/jfree/chart/urls/TimeSeriesURLGenerator.java | /* ===========================================================
* 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.]
*
* ---------------------------
* TimeSeriesURLGenerator.java
* ---------------------------
* (C) Copyright 2002-2008, 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);
*
*/
package org.jfree.chart.urls;
import java.io.Serializable;
import java.text.DateFormat;
import java.util.Date;
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 (<code>null</code> not
* permitted).
* @param prefix the prefix of the URL (<code>null</code> not permitted).
* @param seriesParameterName the name of the series parameter in the URL
* (<code>null</code> not permitted).
* @param itemParameterName the name of the item parameter in the URL
* (<code>null</code> not permitted).
*/
public TimeSeriesURLGenerator(DateFormat dateFormat, String prefix,
String seriesParameterName, String itemParameterName) {
if (dateFormat == null) {
throw new IllegalArgumentException("Null 'dateFormat' argument.");
}
if (prefix == null) {
throw new IllegalArgumentException("Null 'prefix' argument.");
}
if (seriesParameterName == null) {
throw new IllegalArgumentException(
"Null 'seriesParameterName' argument.");
}
if (itemParameterName == null) {
throw new IllegalArgumentException(
"Null 'itemParameterName' argument.");
}
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 <code>null</code>).
*
* @since 1.0.6
*/
public DateFormat getDateFormat() {
return (DateFormat) this.dateFormat.clone();
}
/**
* Returns the prefix string.
*
* @return The prefix string (never <code>null</code>).
*
* @since 1.0.6
*/
public String getPrefix() {
return this.prefix;
}
/**
* Returns the series parameter name.
*
* @return The series parameter name (never <code>null</code>).
*
* @since 1.0.6
*/
public String getSeriesParameterName() {
return this.seriesParameterName;
}
/**
* Returns the item parameter name.
*
* @return The item parameter name (never <code>null</code>).
*
* @since 1.0.6
*/
public String getItemParameterName() {
return this.itemParameterName;
}
/**
* Generates a URL for a particular item within a series.
*
* @param dataset the dataset (<code>null</code> 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 (<code>null</code> 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;
}
}
| 7,454 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
XYZURLGenerator.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/main/java/org/jfree/chart/urls/XYZURLGenerator.java | /* ===========================================================
* 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.]
*
* --------------------
* 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 (<code>null</code> 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);
}
| 2,470 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
StandardXYZURLGenerator.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/main/java/org/jfree/chart/urls/StandardXYZURLGenerator.java | /* ===========================================================
* 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.]
*
* ----------------------------
* 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);
}
}
| 2,194 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
URLUtilities.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/main/java/org/jfree/chart/urls/URLUtilities.java | /* ===========================================================
* 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.]
*
* -----------------
* 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 <code>java.net.URLEncoder.encode(String, String)</code> via
* reflection, if we are running on JRE 1.4 or later, otherwise reverts to
* the deprecated <code>URLEncoder.encode(String)</code> 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;
}
}
| 3,027 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
CustomPieURLGenerator.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/main/java/org/jfree/chart/urls/CustomPieURLGenerator.java | /* ======================================
* JFreeChart : a free Java chart library
* ======================================
*
* (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.]
*
* --------------------------
* CustomPieURLGenerator.java
* --------------------------
* (C) Copyright 2004-2012, 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);
* 17-Jun-2012 : Removed JCommon dependencies (DG);
*
*/
package org.jfree.chart.urls;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.jfree.chart.util.PublicCloneable;
import org.jfree.chart.plot.MultiplePiePlot;
import org.jfree.data.general.PieDataset;
/**
* 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 List<Map<Comparable, String>> urls;
/**
* Creates a new <code>CustomPieURLGenerator</code> instance, initially
* empty. Call {@link #addURLs(Map)} to specify the URL fragments to be
* used.
*/
public CustomPieURLGenerator() {
this.urls = new ArrayList<Map<Comparable, String>>();
}
/**
* 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<Comparable, String> urlMap = 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<Comparable, String> urlMap = this.urls.get(mapIndex);
if (urlMap != null) {
result = urlMap.get(key);
}
}
return result;
}
/**
* Adds a map containing <code>(key, URL)</code> mappings where each
* <code>key</code> is an instance of <code>Comparable</code>
* (corresponding to the key for an item in a pie dataset) and each
* <code>URL</code> is a <code>String</code> representing a URL fragment.
* <br><br>
* 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 (<code>null</code> permitted).
*/
public void addURLs(Map<Comparable, String> 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;
}
for (int pieItem = 0; pieItem < getListCount(); pieItem++) {
if (getURLCount(pieItem) != generator.getURLCount(pieItem)) {
return false;
}
Set<Comparable> keySet = this.urls.get(pieItem).keySet();
for (Comparable key : keySet) {
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 = (CustomPieURLGenerator) super.clone();
urlGen.urls = new ArrayList<Map<Comparable, String>>();
for (Map<Comparable, String> map : this.urls) {
Map<Comparable, String> newMap = new HashMap<Comparable, String>();
for (Map.Entry<Comparable, String> entry : map.entrySet()) {
newMap.put(entry.getKey(), entry.getValue());
}
urlGen.addURLs(newMap);
}
return urlGen;
}
}
| 6,709 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
StandardPieURLGenerator.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/main/java/org/jfree/chart/urls/StandardPieURLGenerator.java | /* ===========================================================
* 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.]
*
* ----------------------------
* StandardPieURLGenerator.java
* ----------------------------
* (C) Copyright 2002-2012, 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);
* 17-Jun-2012 : Removed JCommon dependencies (DG);
*
*/
package org.jfree.chart.urls;
import java.io.Serializable;
import org.jfree.chart.util.ObjectUtilities;
import org.jfree.data.general.PieDataset;
/**
* 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 (<code>null</code> not permitted).
*/
public StandardPieURLGenerator(String prefix) {
this(prefix, "category");
}
/**
* Creates a new generator.
*
* @param prefix the prefix (<code>null</code> not permitted).
* @param categoryParameterName the category parameter name
* (<code>null</code> not permitted).
*/
public StandardPieURLGenerator(String prefix,
String categoryParameterName) {
this(prefix, categoryParameterName, "pieIndex");
}
/**
* Creates a new generator.
*
* @param prefix the prefix (<code>null</code> not permitted).
* @param categoryParameterName the category parameter name
* (<code>null</code> not permitted).
* @param indexParameterName the index parameter name (<code>null</code>
* permitted).
*/
public StandardPieURLGenerator(String prefix,
String categoryParameterName,
String indexParameterName) {
if (prefix == null) {
throw new IllegalArgumentException("Null 'prefix' argument.");
}
if (categoryParameterName == null) {
throw new IllegalArgumentException(
"Null 'categoryParameterName' argument.");
}
this.prefix = prefix;
this.categoryParameterName = categoryParameterName;
this.indexParameterName = indexParameterName;
}
/**
* Generates a URL.
*
* @param dataset the dataset (ignored).
* @param key the item key (<code>null</code> 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 (<code>null</code> 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;
}
}
| 6,354 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
PieURLGenerator.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/main/java/org/jfree/chart/urls/PieURLGenerator.java | /* ===========================================================
* 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.]
*
* --------------------
* 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:
* <ul>
* <li>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;</li>
* <li>should be either (a) immutable, or (b) cloneable via the
* <code>PublicCloneable</code> interface (defined in the JCommon class
* library). This provides a mechanism for the referring plot to clone
* the generator if necessary.</li>
* </ul>
*/
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 (<code>null</code> not permitted).
* @param key the item key (<code>null</code> 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);
}
| 3,214 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
CustomCategoryURLGenerator.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/main/java/org/jfree/chart/urls/CustomCategoryURLGenerator.java | /* ======================================
* JFreeChart : a free Java chart library
* ======================================
*
* (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.]
*
* -------------------------------
* CustomCategoryURLGenerator.java
* -------------------------------
* (C) Copyright 2008-2012, 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);
* 17-Jun-2012 : Removed JCommon dependencies (DG);
*
*/
package org.jfree.chart.urls;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import org.jfree.chart.util.PublicCloneable;
import org.jfree.data.category.CategoryDataset;
/**
* A custom URL generator.
*/
public class CustomCategoryURLGenerator implements CategoryURLGenerator,
Cloneable, PublicCloneable, Serializable {
/** Storage for the URLs. */
private List<List<String>> urlSeries = new ArrayList<List<String>>();
/**
* 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<String> urls = 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 <code>null</code>).
*/
public String getURL(int series, int item) {
String result = null;
if (series < getListCount()) {
List<String> urls = this.urlSeries.get(series);
if (urls != null) {
if (item < urls.size()) {
result = 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 <code>null</code>).
*/
@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 (<code>null</code> permitted).
*/
public void addURLSeries(List<String> urls) {
List<String> listToAdd = null;
if (urls != null) {
listToAdd = new java.util.ArrayList<String>(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<List<String>>(this.urlSeries);
return clone;
}
} | 6,021 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
CustomXYURLGenerator.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/main/java/org/jfree/chart/urls/CustomXYURLGenerator.java | /* ===========================================================
* 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.]
*
* -------------------------
* CustomXYURLGenerator.java
* -------------------------
* (C) Copyright 2002-2012, 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);
* 17-Jun-2012 : Removed JCommon dependencies (DG);
*
*/
package org.jfree.chart.urls;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import org.jfree.chart.util.PublicCloneable;
import org.jfree.data.xy.XYDataset;
/**
* 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 List<List<String>> urlSeries = new ArrayList<List<String>>();
/**
* 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<String> urls = 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 <code>null</code>).
*/
public String getURL(int series, int item) {
String result = null;
if (series < getListCount()) {
List<String> urls = this.urlSeries.get(series);
if (urls != null) {
if (item < urls.size()) {
result = 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 <code>null</code>).
*/
@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 (<code>null</code> permitted, the list
* is copied).
*/
public void addURLSeries(List<String> urls) {
List<String> listToAdd = null;
if (urls != null) {
listToAdd = new java.util.ArrayList<String>(urls);
}
this.urlSeries.add(listToAdd);
}
/**
* Tests this generator for equality with an arbitrary object.
*
* @param obj the object (<code>null</code> 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<List<String>>(this.urlSeries);
return clone;
}
}
| 6,427 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
StandardXYURLGenerator.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/main/java/org/jfree/chart/urls/StandardXYURLGenerator.java | /* ===========================================================
* 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.]
*
* ---------------------------
* StandardXYURLGenerator.java
* ---------------------------
* (C) Copyright 2002-2012, 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);
* 16-Jun-2012 : Removed JCommon dependencies (DG);
*
*/
package org.jfree.chart.urls;
import java.io.Serializable;
import org.jfree.chart.util.ObjectUtilities;
import org.jfree.data.xy.XYDataset;
/**
* 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 <code>StandardXYURLGenerator("index.html", "series", "item");
* </code>.
*/
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
* <code>StandardXYURLGenerator(prefix, "series", "item");</code>.
*
* @param prefix the prefix to the URL (<code>null</code> 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 (<code>null</code> not permitted).
* @param seriesParameterName the name of the series parameter to go in
* each URL (<code>null</code> not permitted).
* @param itemParameterName the name of the item parameter to go in each
* URL (<code>null</code> not permitted).
*/
public StandardXYURLGenerator(String prefix,
String seriesParameterName,
String itemParameterName) {
if (prefix == null) {
throw new IllegalArgumentException("Null 'prefix' argument.");
}
if (seriesParameterName == null) {
throw new IllegalArgumentException(
"Null 'seriesParameterName' argument.");
}
if (itemParameterName == null) {
throw new IllegalArgumentException(
"Null 'itemParameterName' argument.");
}
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 (<code>null</code> 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;
}
}
| 6,503 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
CategoryURLGenerator.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/main/java/org/jfree/chart/urls/CategoryURLGenerator.java | /* ===========================================================
* 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.]
*
* -------------------------
* 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);
}
| 3,112 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
StandardCategoryURLGenerator.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/main/java/org/jfree/chart/urls/StandardCategoryURLGenerator.java | /* ===========================================================
* 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.]
*
* ---------------------------------
* StandardCategoryURLGenerator.java
* ---------------------------------
* (C) Copyright 2002-2012, 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);
* 17-Jun-2012 : Removed JCommon dependencies (DG);
*
*/
package org.jfree.chart.urls;
import java.io.Serializable;
import org.jfree.chart.util.ObjectUtilities;
import org.jfree.data.category.CategoryDataset;
/**
* 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 (<code>null</code> not permitted).
*/
public StandardCategoryURLGenerator(String prefix) {
if (prefix == null) {
throw new IllegalArgumentException("Null 'prefix' argument.");
}
this.prefix = prefix;
}
/**
* Constructor that overrides all the defaults.
*
* @param prefix the prefix to the URL (<code>null</code> not permitted).
* @param seriesParameterName the name of the series parameter to go in
* each URL (<code>null</code> not permitted).
* @param categoryParameterName the name of the category parameter to go in
* each URL (<code>null</code> not permitted).
*/
public StandardCategoryURLGenerator(String prefix,
String seriesParameterName,
String categoryParameterName) {
if (prefix == null) {
throw new IllegalArgumentException("Null 'prefix' argument.");
}
if (seriesParameterName == null) {
throw new IllegalArgumentException(
"Null 'seriesParameterName' argument.");
}
if (categoryParameterName == null) {
throw new IllegalArgumentException(
"Null 'categoryParameterName' argument.");
}
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 (<code>null</code> 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;
}
}
| 7,921 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
package-info.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/main/java/org/jfree/chart/panel/package-info.java | /**
* Classes related to the {@link org.jfree.chart.ChartPanel} class.
*/
package org.jfree.chart.panel;
| 107 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
ZoomHandler.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/main/java/org/jfree/chart/panel/ZoomHandler.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2013, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* 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.]
*
* ----------------
* ZoomHandler.java
* ----------------
* (C) Copyright 2013, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): Michael Zinsmaier;
*
* Changes:
* --------
* 11-Jun-2009 : Version 1 (DG);
*
*/
package org.jfree.chart.panel;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.event.MouseEvent;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.util.ShapeUtilities;
/**
* A mouse handler than performs a zooming operation on a ChartPanel.
*/
public class ZoomHandler extends AbstractMouseHandler {
/** a generated serial id. */
private static final long serialVersionUID = -3796063183854513802L;
private Point2D zoomPoint;
private Rectangle2D zoomRectangle;
public ZoomHandler(int modifier) {
super(modifier);
zoomPoint = null;
}
public ZoomHandler() {
super();
zoomPoint = null;
}
@Override
public void mousePressed(MouseEvent e) {
ChartPanel chartPanel = (ChartPanel) e.getSource();
Rectangle2D screenDataArea = chartPanel.getScreenDataArea(e.getX(),
e.getY());
if (screenDataArea != null) {
this.zoomPoint = ShapeUtilities.getPointInRectangle(e.getX(),
e.getY(), screenDataArea);
}
else {
this.zoomPoint = null;
chartPanel.clearLiveMouseHandler();
}
}
@Override
public void mouseDragged(MouseEvent e) {
ChartPanel panel = (ChartPanel) e.getSource();
if (this.zoomPoint == null) {
//no initial zoom rectangle exists but the handler is set
//as life handler unregister
panel.clearLiveMouseHandler();
return;
}
Graphics2D g2 = (Graphics2D) panel.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 (!panel.getUseBuffer()) {
drawZoomRectangle(panel, g2, true);
}
boolean hZoom, vZoom;
if (panel.getOrientation() == PlotOrientation.HORIZONTAL) {
hZoom = panel.isRangeZoomable();
vZoom = panel.isDomainZoomable();
}
else {
hZoom = panel.isDomainZoomable();
vZoom = panel.isRangeZoomable();
}
Rectangle2D scaledDataArea = panel.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());
}
panel.setZoomRectangle(this.zoomRectangle);
// Draw the new zoom rectangle...
if (panel.getUseBuffer()) {
panel.repaint();
}
else {
// with no buffer, we use XOR to draw the rectangle "over" the
// chart...
drawZoomRectangle(panel, g2, true);
}
g2.dispose();
}
@Override
public void mouseReleased(MouseEvent e) {
ChartPanel panel = (ChartPanel) e.getSource();
if (this.zoomRectangle == null) {
//no initial zoom rectangle exists but the handler is set
//as life handler unregister
panel.clearLiveMouseHandler();
return;
}
boolean hZoom, vZoom;
if (panel.getOrientation() == PlotOrientation.HORIZONTAL) {
hZoom = panel.isRangeZoomable();
vZoom = panel.isDomainZoomable();
}
else {
hZoom = panel.isDomainZoomable();
vZoom = panel.isRangeZoomable();
}
boolean zoomTrigger1 = hZoom && Math.abs(e.getX()
- this.zoomPoint.getX()) >= panel.getZoomTriggerDistance();
boolean zoomTrigger2 = vZoom && Math.abs(e.getY()
- this.zoomPoint.getY()) >= panel.getZoomTriggerDistance();
if (zoomTrigger1 || zoomTrigger2) {
if ((hZoom && (e.getX() < this.zoomPoint.getX()))
|| (vZoom && (e.getY() < this.zoomPoint.getY()))) {
panel.restoreAutoBounds();
}
else {
double x, y, w, h;
Rectangle2D screenDataArea = panel.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);
panel.zoom(zoomArea);
}
this.zoomPoint = null;
this.zoomRectangle = null;
panel.setZoomRectangle(null);
panel.clearLiveMouseHandler();
}
else {
// erase the zoom rectangle
Graphics2D g2 = (Graphics2D) panel.getGraphics();
if (panel.getUseBuffer()) {
panel.repaint();
}
else {
drawZoomRectangle(panel, g2, true);
}
g2.dispose();
this.zoomPoint = null;
this.zoomRectangle = null;
panel.setZoomRectangle(null);
panel.clearLiveMouseHandler();
}
}
/**
* 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(ChartPanel panel, Graphics2D g2,
boolean xor) {
if (this.zoomRectangle != null) {
if (xor) {
// Set XOR mode to draw the zoom rectangle
g2.setXORMode(Color.gray);
}
if (panel.getFillZoomRectangle()) {
g2.setPaint(panel.getZoomFillPaint());
g2.fill(this.zoomRectangle);
}
else {
g2.setPaint(panel.getZoomOutlinePaint());
g2.draw(this.zoomRectangle);
}
if (xor) {
// Reset to the default 'overwrite' mode
g2.setPaintMode();
}
}
}
/**
* @see AbstractMouseHandler#isLiveHandler()
*/
public boolean isLiveHandler() {
return true;
}
}
| 10,192 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
CrosshairOverlay.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/main/java/org/jfree/chart/panel/CrosshairOverlay.java | /* ===========================================================
* 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.]
*
* ---------------------
* CrosshairOverlay.java
* ---------------------
* (C) Copyright 2011, 2012, 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);
* 17-Jun-2012 : Removed JCommon dependencies (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.List;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.ValueAxis;
import org.jfree.chart.ui.RectangleAnchor;
import org.jfree.chart.ui.RectangleEdge;
import org.jfree.chart.ui.TextAnchor;
import org.jfree.chart.util.ObjectUtilities;
import org.jfree.chart.util.PublicCloneable;
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.text.TextUtilities;
/**
* 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<Crosshair> xCrosshairs;
/** Storage for the crosshairs along the y-axis. */
private List<Crosshair> yCrosshairs;
/**
* Default constructor.
*/
public CrosshairOverlay() {
super();
this.xCrosshairs = new java.util.ArrayList<Crosshair>();
this.yCrosshairs = new java.util.ArrayList<Crosshair>();
}
/**
* Adds a crosshair against the domain axis and sends an
* {@link OverlayChangeEvent} to all registered listeners.
*
* @param crosshair the crosshair (<code>null</code> not permitted).
*
* @see #removeDomainCrosshair(org.jfree.chart.plot.Crosshair)
* @see #addRangeCrosshair(org.jfree.chart.plot.Crosshair)
*/
public void addDomainCrosshair(Crosshair crosshair) {
if (crosshair == null) {
throw new IllegalArgumentException("Null 'crosshair' argument.");
}
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 (<code>null</code> not permitted).
*
* @see #addDomainCrosshair(org.jfree.chart.plot.Crosshair)
*/
public void removeDomainCrosshair(Crosshair crosshair) {
if (crosshair == null) {
throw new IllegalArgumentException("Null 'crosshair' argument.");
}
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<Crosshair> crosshairs = getDomainCrosshairs();
for (Crosshair crosshair : crosshairs) {
Crosshair c = crosshair;
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<Crosshair> getDomainCrosshairs() {
return new ArrayList<Crosshair>(this.xCrosshairs);
}
/**
* Adds a crosshair against the range axis and sends an
* {@link OverlayChangeEvent} to all registered listeners.
*
* @param crosshair the crosshair (<code>null</code> not permitted).
*/
public void addRangeCrosshair(Crosshair crosshair) {
if (crosshair == null) {
throw new IllegalArgumentException("Null 'crosshair' argument.");
}
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 (<code>null</code> not permitted).
*
* @see #addRangeCrosshair(org.jfree.chart.plot.Crosshair)
*/
public void removeRangeCrosshair(Crosshair crosshair) {
if (crosshair == null) {
throw new IllegalArgumentException("Null 'crosshair' argument.");
}
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<Crosshair> crosshairs = getRangeCrosshairs();
for (Crosshair crosshair : crosshairs) {
Crosshair c = crosshair;
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<Crosshair> getRangeCrosshairs() {
return new ArrayList<Crosshair>(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();
for (Crosshair ch : this.xCrosshairs) {
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();
for (Crosshair ch : this.yCrosshairs) {
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 = 0.0;
double y = 0.0;
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 (<code>null</code> 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 = ObjectUtilities.deepClone(this.xCrosshairs);
clone.yCrosshairs = ObjectUtilities.deepClone(this.yCrosshairs);
return clone;
}
}
| 21,399 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
AbstractMouseHandler.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/main/java/org/jfree/chart/panel/AbstractMouseHandler.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2009, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* 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.]
*
* -------------------------
* AbstractMouseHandler.java
* -------------------------
* (C) Copyright 2009, by Object Refinery Limited.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes:
* --------
* 18-Jun-2009 : Version 1 (DG);
*
*/
package org.jfree.chart.panel;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import java.io.Serializable;
import org.jfree.chart.ChartPanel;
/**
* A handler for mouse events in a {@link ChartPanel}. A handler can be
* assigned a modifier and installed on the panel to be invoked by the user.
*/
public abstract class AbstractMouseHandler implements MouseListener,
MouseMotionListener, Serializable {
/** a generated serial id. */
private static final long serialVersionUID = -2717376020576340947L;
/** The modifier used to invoke this handler. */
private int modifier;
/**
* Default constructor.
*/
public AbstractMouseHandler() {
this.modifier = 0;
}
/**
* Constructing with modifier.
*/
public AbstractMouseHandler(int modifier) {
this.modifier = modifier;
}
/**
* Returns the modifier for this handler.
*
* @return The modifier.
*/
public int getModifier() {
return this.modifier;
}
/**
* Sets the modifier for this handler.
*
* @param modifier the modifier.
*/
public void setModifier(int modifier) {
this.modifier = modifier;
}
/**
* Handle a mouse pressed event. This implementation does nothing -
* subclasses should override if necessary.
*
* @param e the mouse event.
*/
public void mousePressed(MouseEvent e) {
// override to do something
}
/**
* Handle a mouse released event. This implementation does nothing -
* subclasses should override if necessary.
*
* @param e the mouse event.
*/
public void mouseReleased(MouseEvent e) {
// override if you need this method to do something
}
/**
* Handle a mouse clicked event. This implementation does nothing -
* subclasses should override if necessary.
*
* @param e the mouse event.
*/
public void mouseClicked(MouseEvent e) {
// override if you need this method to do something
}
/**
* Handle a mouse entered event. This implementation does nothing -
* subclasses should override if necessary.
*
* @param e the mouse event.
*/
public void mouseEntered(MouseEvent e) {
// override if you need this method to do something
}
/**
* Handle a mouse moved event. This implementation does nothing -
* subclasses should override if necessary.
*
* @param e the mouse event.
*/
public void mouseMoved(MouseEvent e) {
// override if you need this method to do something
}
/**
* Handle a mouse exited event. This implementation does nothing -
* subclasses should override if necessary.
*
* @param e the mouse event.
*/
public void mouseExited(MouseEvent e) {
// override if you need this method to do something
}
/**
* Handle a mouse dragged event. This implementation does nothing -
* subclasses should override if necessary.
*
* @param e the mouse event.
*/
public void mouseDragged(MouseEvent e) {
// override if you need this method to do something
}
/**
* A mouse handler is either an live handler or an auxiliary handler. While
* there can be only one active live handler at a time many auxiliary
* handlers can be used together. E.g. rectangle zooming and rectangle
* selection should be implemented as live handlers because they both draw
* on the panel and shouldn't be combined. In contrast a click selection
* does not interfere with e.g. a double click selection both handlers can
* be active at the same time.
*
* @return true if this is a live handler
*/
public abstract boolean isLiveHandler();
}
| 5,410 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
AbstractOverlay.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/main/java/org/jfree/chart/panel/AbstractOverlay.java | /* ===========================================================
* 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.]
*
* --------------------
* AbstractOverlay.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 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;
/**
* 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 (<code>null</code> not permitted).
*
* @see #removeChangeListener(OverlayChangeListener)
*/
public void addChangeListener(OverlayChangeListener listener) {
if (listener == null) {
throw new IllegalArgumentException("Null 'listener' argument.");
}
this.changeListeners.add(OverlayChangeListener.class, listener);
}
/**
* Deregisters an object for notification of changes to the overlay.
*
* @param listener the listener (<code>null</code> not permitted)
*
* @see #addChangeListener(OverlayChangeListener)
*/
public void removeChangeListener(OverlayChangeListener listener) {
if (listener == null) {
throw new IllegalArgumentException("Null 'listener' argument.");
}
this.changeListeners.remove(OverlayChangeListener.class, listener);
}
/**
* Sends a default {@link ChartChangeEvent} to all registered listeners.
* <P>
* 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);
}
}
}
}
| 4,024 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
PanHandler.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/main/java/org/jfree/chart/panel/PanHandler.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2013, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* 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.]
*
* ---------------
* PanHandler.java
* ---------------
* (C) Copyright 2009-2013, by Object Refinery Limited.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes:
* --------
* 11-Jun-2009 : Version 1 (DG);
*
*/
package org.jfree.chart.panel;
import java.awt.Cursor;
import java.awt.Point;
import java.awt.event.MouseEvent;
import java.awt.geom.Rectangle2D;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.Pannable;
import org.jfree.chart.plot.Plot;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.plot.PlotRenderingInfo;
/**
* Handles panning operations in a {@link ChartPanel} if the plot supports
* them.
*/
public class PanHandler extends AbstractMouseHandler {
/** a generated serial id. */
private static final long serialVersionUID = -2454906267665359292L;
/**
* 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;
public PanHandler(int modifier) {
super(modifier);
this.panLast = null;
}
public PanHandler() {
super();
this.panLast = null;
}
@Override
public void mousePressed(MouseEvent e) {
ChartPanel panel = (ChartPanel) e.getSource();
Plot plot = panel.getChart().getPlot();
if (!(plot instanceof Pannable)) {
panel.clearLiveMouseHandler();
return; // there's nothing for us to do (except unregistering)
}
Pannable pannable = (Pannable) plot;
if (pannable.isDomainPannable() || pannable.isRangePannable()) {
Rectangle2D screenDataArea = panel.getScreenDataArea(e.getX(),
e.getY());
if (screenDataArea != null && screenDataArea.contains(
e.getPoint())) {
this.panW = screenDataArea.getWidth();
this.panH = screenDataArea.getHeight();
this.panLast = e.getPoint();
panel.setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR));
}
}
// the actual panning occurs later in the mouseDragged() method
}
@Override
public void mouseDragged(MouseEvent e) {
ChartPanel panel = (ChartPanel) e.getSource();
if (this.panLast == null) {
//handle panning if we have a start point else unregister
panel.clearLiveMouseHandler();
return;
}
JFreeChart chart = panel.getChart();
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 = chart.getPlot().isNotify();
chart.getPlot().setNotify(false);
Pannable p = (Pannable) chart.getPlot();
PlotRenderingInfo info = panel.getChartRenderingInfo().getPlotInfo();
if (p.getOrientation() == PlotOrientation.VERTICAL) {
p.panDomainAxes(wPercent, info, this.panLast);
p.panRangeAxes(hPercent, info, this.panLast);
}
else {
p.panDomainAxes(hPercent, info, this.panLast);
p.panRangeAxes(wPercent, info, this.panLast);
}
this.panLast = e.getPoint();
chart.getPlot().setNotify(old);
}
@Override
public void mouseReleased(MouseEvent e) {
ChartPanel panel = (ChartPanel) e.getSource();
//if we have been panning reset the cursor
//unregister in any case
if (this.panLast != null) {
panel.setCursor(Cursor.getDefaultCursor());
}
this.panLast = null;
panel.clearLiveMouseHandler();
}
/**
* @see AbstractMouseHandler#isLiveHandler()
*/
public boolean isLiveHandler() {
return true;
}
}
| 5,267 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
Overlay.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/main/java/org/jfree/chart/panel/Overlay.java | /* ===========================================================
* 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.]
*
* ------------
* 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);
}
| 2,356 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
MouseClickSelectionHandler.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/main/java/org/jfree/chart/panel/selectionhandler/MouseClickSelectionHandler.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2013, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* 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.]
*
* -------------------------------
* MouseClickSelectionHandler.java
* -------------------------------
* (C) Copyright 2013, by Michael Zinsmaier and Contributors.
*
* Original Author: Michael Zinsmaier;
* Contributor(s): David Gilbert (for Object Refinery Limited);
*
* Changes:
* --------
* 17-Sep-2013 : Version 1 (DG);
*
*/
package org.jfree.chart.panel.selectionhandler;
import java.awt.event.MouseEvent;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.panel.AbstractMouseHandler;
/**
* An auxiliary mouse handler that selects data items on click.
*
* Will only work together with a ChartPanel as event source
*
* @author zinsmaie
*/
public class MouseClickSelectionHandler extends AbstractMouseHandler {
/** a generated serial id. */
private static final long serialVersionUID = 1101598509484156300L;
/**
* default constructor
*/
public MouseClickSelectionHandler() {
super();
}
/**
* Creates a new instance with a modifier restriction
* @param modifier e.g. shift has to be pressed InputEvents.SHIFT_MASK
*/
public MouseClickSelectionHandler(int modifier) {
super(modifier);
}
/**
* point wise selection
* <br><br>
* delegates to the {@link SelectionManager} of the ChartPanel, this
* listener is paired with.
*/
@Override
public void mouseClicked(MouseEvent e) {
if (!(e.getSource() instanceof ChartPanel)) {
return;
}
ChartPanel panel = (ChartPanel)e.getSource();
SelectionManager selectionManager = panel.getSelectionManager();
if (selectionManager != null) {
if (!e.isShiftDown()) {
selectionManager.clearSelection();
panel.getChart().fireChartChanged();
}
selectionManager.select(e.getX(), e.getY());
panel.getChart().fireChartChanged();
}
}
/**
* this is not a live handler
*/
public boolean isLiveHandler() {
return false;
}
}
| 3,316 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
EntitySelectionManager.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/main/java/org/jfree/chart/panel/selectionhandler/EntitySelectionManager.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2013, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* 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.]
*
* ---------------------------
* EntitySelectionManager.java
* ---------------------------
* (C) Copyright 2013, by Michael Zinsmaier and Contributors.
*
* Original Author: Michael Zinsmaier;
* Contributor(s): David Gilbert (for Object Refinery Limited);
*
* Changes:
* --------
* 17-Sep-2013 : Version 1 from MZ (DG);
*
*/
package org.jfree.chart.panel.selectionhandler;
import java.awt.geom.AffineTransform;
import java.awt.geom.Area;
import java.awt.geom.GeneralPath;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.entity.ChartEntity;
import org.jfree.chart.entity.DataItemEntity;
import org.jfree.chart.entity.EntityCollection;
import org.jfree.data.extension.DatasetCursor;
import org.jfree.data.extension.DatasetSelectionExtension;
import org.jfree.data.extension.impl.DatasetExtensionManager;
import org.jfree.data.general.Dataset;
/**
* Selects data items based on the shape of their rendered entities and a given
* point or region selection in the ChartPanel plane.<br>
* <br>
* region selection:<br>
* Depending on the rendering mode {@link #intersectionMode} selects either all
* entities that intersect the selection region or all entities that are
* completely inside the selection region.<br>
* <br>
* point selection:<br>
* Selects all entities that contain the selection point <br>
* <br>
* The entities are retrieved from the ChartPanel
*
* @author zinsmaie
*/
public class EntitySelectionManager implements SelectionManager {
/** a generated serial id. */
private static final long serialVersionUID = -8963792184797912675L;
/**
* if true a entity has to intersect the selection region to be selected if
* false a entity has to be completely inside the selection region to be
* selected.
*/
private boolean intersectionMode;
/** the ChartPanel this manager is registered on */
private final ChartPanel renderSourcePanel;
/**
* couples datasets and selection information of datasets that do not
* support {@link DatasetSelectionExtension}
*/
private final DatasetExtensionManager extensionManager;
/** all datasets that are handled by the manager. */
private final Dataset[] datasets;
/**
* Constructs a new selection manager. Use this constructor if all datasets
* support {@link DatasetSelectionExtension}
*
* @param renderSourcePanel {@link #renderSourcePanel}
* @param datasets {@link #datasets}
*/
public EntitySelectionManager(ChartPanel renderSourcePanel,
Dataset[] datasets) {
this.renderSourcePanel = renderSourcePanel;
this.datasets = datasets;
// initialize an extension manager without registered extensions
this.extensionManager = new DatasetExtensionManager();
this.intersectionMode = false;
}
/**
* constructs a new selection manager and provides a extension manager. Use
* this constructor if some of the used datasets do not support
* {@link DatasetSelectionExtension}. These datasets can be coupled with
* appropriate helper objects by registering them to the extension manager
* before the constructor call.
*
* @param renderSourcePanel {@link #renderSourcePanel}
* @param datasets {@link #datasets}
* @param extensionManager {@link #extensionManager}
*/
public EntitySelectionManager(ChartPanel renderSourcePanel,
Dataset[] datasets, DatasetExtensionManager extensionManager) {
this.renderSourcePanel = renderSourcePanel;
this.datasets = datasets;
// set an extension manager that may manager helper objects to extend
// old datasets
this.extensionManager = extensionManager;
this.intersectionMode = false;
}
/**
* @param on {@link #intersectionMode}
*/
public void setIntersectionSelection(boolean on) {
this.intersectionMode = on;
}
/**
* {@link SelectionManager#select(double, double)} <br>
* Selection based on the shape of the data items
*/
public void select(double x, double y) {
// scale if necessary
double scaleX = this.renderSourcePanel.getScaleX();
double scaleY = this.renderSourcePanel.getScaleY();
if (scaleX != 1.0d || scaleY != 1.0d) {
x = x / scaleX;
y = y / scaleY;
}
if (this.renderSourcePanel.getChartRenderingInfo() != null) {
EntityCollection entities = this.renderSourcePanel
.getChartRenderingInfo().getEntityCollection();
for (ChartEntity ce : entities.getEntities()) {
if (ce instanceof DataItemEntity) {
DataItemEntity e = (DataItemEntity) ce;
// simple check if the entity shape area contains the point
if (e.getArea().contains(new Point2D.Double(x, y))) {
select(e);
}
}
}
}
}
/**
*
* {@link SelectionManager#select(Rectangle2D)} <br>
* Selection based on the shape of the data items
*/
public void select(Rectangle2D pSelection) {
// scale if necessary
Rectangle2D selection;
double scaleX = this.renderSourcePanel.getScaleX();
double scaleY = this.renderSourcePanel.getScaleY();
if (scaleX != 1.0d || scaleY != 1.0d) {
AffineTransform st = AffineTransform.getScaleInstance(1.0 / scaleX,
1.0 / scaleY);
Area selectionArea = new Area(pSelection);
selectionArea.transform(st);
selection = selectionArea.getBounds2D();
} else {
selection = pSelection;
}
if (this.renderSourcePanel.getChartRenderingInfo() != null) {
muteAll();
{
EntityCollection entities = this.renderSourcePanel
.getChartRenderingInfo().getEntityCollection();
for (ChartEntity ce : entities.getEntities()) {
if (ce instanceof DataItemEntity) {
DataItemEntity e = (DataItemEntity) ce;
boolean match;
if (e.getArea() instanceof Rectangle2D) {
Rectangle2D entityRect = (Rectangle2D) e.getArea();
// use fast rectangle to rectangle test
if (this.intersectionMode) {
match = selection.intersects(entityRect);
} else {
match = selection.contains(entityRect);
}
} else {
// general shape test
Area selectionShape = new Area(selection);
Area entityShape = new Area(e.getArea());
// fast test if completely inside the solution must be true
if (selectionShape.contains(entityShape.getBounds())) {
match = true;
} else {
if (this.intersectionMode) {
// test if the shapes intersect
entityShape.intersect(selectionShape);
match = !entityShape.isEmpty();
} else {
// test if the entity shape is completely
// covered by the selection
entityShape.subtract(selectionShape);
match = entityShape.isEmpty();
}
}
}
if (match) {
select(e);
}
}
}
}
unmuteAndTrigger();
}
}
/**
* {@link SelectionManager#select(GeneralPath)} <br>
* Selection based on the shape of the data items
*/
public void select(GeneralPath pSelection) {
// scale if necessary
GeneralPath selection;
double scaleX = this.renderSourcePanel.getScaleX();
double scaleY = this.renderSourcePanel.getScaleY();
if (scaleX != 1.0d || scaleY != 1.0d) {
AffineTransform st = AffineTransform.getScaleInstance(1.0 / scaleX,
1.0 / scaleY);
Area selectionArea = new Area(pSelection);
selectionArea.transform(st);
selection = new GeneralPath(selectionArea);
} else {
selection = pSelection;
}
if (this.renderSourcePanel.getChartRenderingInfo() != null) {
muteAll();
{
EntityCollection entities = this.renderSourcePanel
.getChartRenderingInfo().getEntityCollection();
for (ChartEntity ce : entities.getEntities()) {
if (ce instanceof DataItemEntity) {
DataItemEntity e = (DataItemEntity) ce;
Area selectionShape = new Area(selection);
Area entityShape = new Area(e.getArea());
// fast test if completely inside the solution must be true
if (selectionShape.contains(entityShape.getBounds())) {
select(e);
} else {
if (this.intersectionMode) {
// test if the shapes intersect
entityShape.intersect(selectionShape);
if (!entityShape.isEmpty()) {
select(e);
}
} else {
// test if the entity shape is completely covered by
//the selection
entityShape.subtract(selectionShape);
if (entityShape.isEmpty()) {
select(e);
}
}
}
}
}
}
unmuteAndTrigger();
}
}
/**
* {@link SelectionManager#clearSelection()}
*/
public void clearSelection() {
for (int i = 0; i < this.datasets.length; i++) {
if (this.extensionManager.supports(this.datasets[i],
DatasetSelectionExtension.class)) {
DatasetSelectionExtension<?> selectionExtension
= (DatasetSelectionExtension<?>) this.extensionManager
.getExtension(this.datasets[i],
DatasetSelectionExtension.class);
selectionExtension.clearSelection();
}
}
}
/**
* tests if the dataset is handled by the selection manager (part of
* {@link #datasets}) and if it either supports
* {@link DatasetSelectionExtension} directly or via the extension manager.<br>
* <br>
* The selects the specified data item.
*
* @param e
* data item that should be selected
*/
private void select(DataItemEntity e) {
// to support propper clear functionality we must maintain
// all datasets that we change!
boolean handled = false;
for (int i = 0; i < this.datasets.length; i++) {
if (datasets[i].equals(e.getGeneralDataset())) {
handled = true;
break;
}
}
if (handled) {
if (this.extensionManager.supports(e.getGeneralDataset(),
DatasetSelectionExtension.class)) {
//TODO a type save solution would be nice
DatasetCursor cursor = e.getItemCursor();
DatasetSelectionExtension selectionExtension
= this.extensionManager.getExtension(
e.getGeneralDataset(),
DatasetSelectionExtension.class);
// work on the data
selectionExtension.setSelected(cursor, true);
}
}
}
/**
* mutes the selection change listener for all handled datasets (in
* {@link #datasets} and supports {@link DatasetSelectionExtension}
*/
private void muteAll() {
setNotifyOnListenerExtensions(false);
}
/**
* unmutes the selection change listener for all handled datasets (in
* {@link #datasets} and supports {@link DatasetSelectionExtension}
*
* unmute should trigger a selection changed event if something happened
* since mute (but this is controlled by the implementing classes and can
* only be assumed here)
*/
private void unmuteAndTrigger() {
setNotifyOnListenerExtensions(true);
}
/**
* mutes / unmutes the selection change listener for all handled datasets
* (in {@link #datasets} and supports {@link DatasetSelectionExtension}
*
* unmute should trigger a selection changed event if something happened
* since mute (but this is controlled by the implementing classes and can
* only be assumed here)
*
* @param notify
* false to mute true to unmute
*/
private void setNotifyOnListenerExtensions(boolean notify) {
for (int i = 0; i < this.datasets.length; i++) {
if (this.extensionManager.supports(datasets[i],
DatasetSelectionExtension.class)) {
DatasetSelectionExtension<?> selectionExtension
= (DatasetSelectionExtension<?>) this.extensionManager
.getExtension(datasets[i],
DatasetSelectionExtension.class);
selectionExtension.setNotify(notify);
}
}
}
}
| 15,534 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
FreeRegionSelectionHandler.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/main/java/org/jfree/chart/panel/selectionhandler/FreeRegionSelectionHandler.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2013, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* 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.]
*
* -------------------------------
* FreeRegionSelectionHandler.java
* -------------------------------
* (C) Copyright 2009-2013, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): Michael Zinsmaier;
*
* Changes:
* --------
* 19-Jun-2009 : Version 1 (DG);
*
*/
package org.jfree.chart.panel.selectionhandler;
import java.awt.Paint;
import java.awt.Point;
import java.awt.Stroke;
import java.awt.event.MouseEvent;
import java.awt.geom.GeneralPath;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.util.ShapeUtilities;
/**
* A mouse handler that allows data items to be selected. The selection shape
* can be freely manipulated by dragging the mouse away from the starting
* point.
*
* Will only work together with a ChartPanel as event source
*/
public class FreeRegionSelectionHandler extends RegionSelectionHandler {
/** a generated serial id. */
private static final long serialVersionUID = -7866645942943333511L;
/**
* The selection path (in Java2D space).
*/
private GeneralPath selectionPath;
/**
* The start mouse point.
*/
private Point2D lastPoint;
/**
* Creates a new default instance.
*/
public FreeRegionSelectionHandler() {
super();
this.selectionPath = new GeneralPath();
this.lastPoint = null;
}
/**
* Creates a new instance with a modifier restriction
* @param modifier e.g. shift has to be pressed InputEvents.SHIFT_MASK
*/
public FreeRegionSelectionHandler(int modifier) {
super(modifier);
this.selectionPath = new GeneralPath();
this.lastPoint = null;
}
/**
* Creates a new selection handler with the specified attributes.
*
* @param outlineStroke the outline stroke.
* @param outlinePaint the outline paint.
* @param fillPaint the fill paint.
*/
public FreeRegionSelectionHandler(Stroke outlineStroke, Paint outlinePaint,
Paint fillPaint) {
super(outlineStroke, outlinePaint, fillPaint);
this.selectionPath = new GeneralPath();
this.lastPoint = null;
}
/**
* starts the region selection by fixing the start point of the selection path
*
* @param e the event.
*/
public void mousePressed(MouseEvent e) {
if (!(e.getSource() instanceof ChartPanel)) {
return;
}
ChartPanel panel = (ChartPanel) e.getSource();
Rectangle2D dataArea = panel.getScreenDataArea();
if (dataArea.contains(e.getPoint())) {
SelectionManager selectionManager = panel.getSelectionManager();
if (selectionManager != null) {
if (!e.isShiftDown()) {
selectionManager.clearSelection();
}
Point pt = e.getPoint();
this.selectionPath.moveTo(pt.getX(), pt.getY());
this.lastPoint = new Point(pt);
}
}
}
/**
* adjusts the selection by adding a new line segment from the last to the
* actual position
*
* @param e the event.
*/
public void mouseDragged(MouseEvent e) {
ChartPanel panel = (ChartPanel) e.getSource();
if (this.lastPoint == null) {
panel.clearLiveMouseHandler();
return; // we never started a selection
}
Point pt = e.getPoint();
Point2D pt2 = ShapeUtilities.getPointInRectangle(pt.x, pt.y,
panel.getScreenDataArea());
if (pt2.distance(this.lastPoint) > 5) {
this.selectionPath.lineTo(pt2.getX(), pt2.getY());
this.lastPoint = pt2;
}
panel.setSelectionShape(selectionPath);
panel.setSelectionFillPaint(this.fillPaint);
panel.setSelectionOutlinePaint(this.outlinePaint);
panel.repaint();
}
/**
* finishes the selection and calls the {@link SelectionManager} of
* the event source. The SelectionManager is then responsible for the processing
* of the geometric selection.
*/
public void mouseReleased(MouseEvent e) {
ChartPanel panel = (ChartPanel) e.getSource();
if (this.lastPoint == null) {
panel.clearLiveMouseHandler();
return; // we never started a selection
}
this.selectionPath.closePath();
SelectionManager selectionManager = panel.getSelectionManager();
// do something with the selection shape
if (selectionManager != null) {
selectionManager.select(this.selectionPath);
}
panel.setSelectionShape(null);
this.selectionPath.reset();
this.lastPoint = null;
panel.repaint();
panel.clearLiveMouseHandler();
}
}
| 6,123 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
FreePathSelectionHandler.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/main/java/org/jfree/chart/panel/selectionhandler/FreePathSelectionHandler.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2013, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* 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.]
*
* -----------------------------
* FreePathSelectionHandler.java
* -----------------------------
* (C) Copyright 2013, by Michael Zinsmaier and Contributors.
*
* Original Author: Michael Zinsmaier;
* Contributor(s): David Gilbert (for Object Refinery Limited);
*
* Changes:
* --------
* 17-Sep-2013 : Version 1 from MZ (DG);
*
*/
package org.jfree.chart.panel.selectionhandler;
import java.awt.Color;
import java.awt.Paint;
import java.awt.Point;
import java.awt.Stroke;
import java.awt.event.MouseEvent;
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.ChartPanel;
import org.jfree.chart.util.ShapeUtilities;
/**
* A mouse handler that allows data items to be selected. The selection path
* can be freely manipulated by dragging the mouse away from the starting
* point. This selection handler is intended for intersection based selection.
*
* Will only work together with a ChartPanel as event source
*/
public class FreePathSelectionHandler extends RegionSelectionHandler {
/** a generated serial id. */
private static final long serialVersionUID = 8051992918085934799L;
/**
* temporary storage for points
*/
private List<Point> points;
/**
* The selection path (in Java2D space).
*/
private GeneralPath selectionPath;
/**
* The start mouse point.
*/
private Point2D lastPoint;
/**
* Creates a new default instance.
*/
public FreePathSelectionHandler() {
this.selectionPath = new GeneralPath();
this.lastPoint = null;
this.points = new ArrayList<Point>();
setFillPaint(Color.GRAY);
setOutlinePaint(new Color(0,160,230));
}
/**
* Creates a new instance with a modifier restriction
* @param modifier e.g. shift has to be pressed InputEvents.SHIFT_MASK
*/
public FreePathSelectionHandler(int modifier) {
super(modifier);
this.selectionPath = new GeneralPath();
this.lastPoint = null;
this.points = new ArrayList<Point>();
setFillPaint(Color.GRAY);
setOutlinePaint(new Color(0,160,230));
}
/**
* Creates a new selection handler with the specified attributes.
*
* @param outlineStroke the outline stroke.
* @param outlinePaint the outline paint.
* @param fillPaint the fill paint.
*/
public FreePathSelectionHandler(Stroke outlineStroke, Paint outlinePaint,
Paint fillPaint) {
super(outlineStroke, outlinePaint, fillPaint);
this.selectionPath = new GeneralPath();
this.lastPoint = null;
this.points = new ArrayList<Point>();
}
/**
* starts the selection by fixing the start point of the selection path
*
* @param e the event.
*/
public void mousePressed(MouseEvent e) {
if (!(e.getSource() instanceof ChartPanel)) {
return;
}
ChartPanel panel = (ChartPanel) e.getSource();
Rectangle2D dataArea = panel.getScreenDataArea();
if (dataArea.contains(e.getPoint())) {
SelectionManager selectionManager = panel.getSelectionManager();
if (selectionManager != null) {
if (!e.isShiftDown()) {
selectionManager.clearSelection();
}
Point pt = e.getPoint();
this.lastPoint = new Point(pt);
this.points.add(pt);
}
}
}
/**
* adjusts the selection by adding a new line segment from the last to the
* actual position
*
* @param e the event.
*/
public void mouseDragged(MouseEvent e) {
ChartPanel panel = (ChartPanel) e.getSource();
if (this.lastPoint == null) {
panel.clearLiveMouseHandler();
return; // we never started a selection
}
Point pt = e.getPoint();
Point2D pt2 = ShapeUtilities.getPointInRectangle(pt.x, pt.y,
panel.getScreenDataArea());
if (pt2.distance(this.lastPoint) > 5) {
this.points.add(new Point((int)pt2.getX(), (int)pt2.getY()));
this.lastPoint = pt2;
}
selectionPath = createPathFromPoints(this.points);
panel.setSelectionShape(selectionPath);
panel.setSelectionFillPaint(this.fillPaint);
panel.setSelectionOutlinePaint(this.outlinePaint);
panel.repaint();
}
/**
* finishes the selection and calls the {@link SelectionManager} of
* the event source. The SelectionManager is then responsible for the processing
* of the geometric selection.
*/
public void mouseReleased(MouseEvent e) {
ChartPanel panel = (ChartPanel) e.getSource();
if (this.lastPoint == null) {
panel.clearLiveMouseHandler();
return; // we never started a selection
}
this.selectionPath = createPathFromPoints(this.points);
this.selectionPath.closePath();
SelectionManager selectionManager = panel.getSelectionManager();
// do something with the selection shape
if (selectionManager != null) {
selectionManager.select(this.selectionPath);
}
panel.setSelectionShape(null);
this.selectionPath.reset();
this.points.clear();
this.lastPoint = null;
panel.repaint();
panel.clearLiveMouseHandler();
}
/**
* creates a line shape from a series of points
*
* @param points
* @return the line shape
*/
private GeneralPath createPathFromPoints(List<Point> points) {
GeneralPath path = new GeneralPath();
if (points.size() > 0) {
Point p = points.get(0);
path.moveTo(p.getX(), p.getY());
}
for (int i = 1; i < points.size(); i++) {
Point p = points.get(i);
path.lineTo((p.getX() - 1), (p.getY() + 1));
path.lineTo((p.getX() + 1), (p.getY() + 1));
}
for (int i = (points.size() -1); i >= 0; i--) {
Point p = points.get(i);
path.lineTo((p.getX() + 1), (p.getY() - 1));
path.lineTo((p.getX() - 1), (p.getY() - 1));
}
return path;
}
}
| 7,628 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
RegionSelectionHandler.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/main/java/org/jfree/chart/panel/selectionhandler/RegionSelectionHandler.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2013, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* 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.]
*
* ---------------------------
* RegionSelectionHandler.java
* ---------------------------
* (C) Copyright 2009-2013, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): Michael Zinsmaier;
*
* Changes:
* --------
* 19-Jun-2009 : Version 1 (DG);
*
*/
package org.jfree.chart.panel.selectionhandler;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Paint;
import java.awt.Stroke;
import java.awt.event.MouseEvent;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import org.jfree.chart.panel.AbstractMouseHandler;
import org.jfree.chart.util.SerialUtilities;
/**
* A mouse handler that allows data items to be selected based on a selection
* region that is created by the handler.
*/
public abstract class RegionSelectionHandler extends AbstractMouseHandler {
/** a generated serial id. */
private static final long serialVersionUID = -4671799719995583469L;
/**
* The outline stroke.
*/
protected transient Stroke outlineStroke;
/**
* The outline paint.
*/
protected transient Paint outlinePaint;
/**
* The fill paint.
*/
protected transient Paint fillPaint;
private static final Stroke DEFAULT_OUTLINE_STROKE = new BasicStroke(1.0f,
BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 2.0f,
new float[] {3f, 3f}, 0f);
/**
* Creates a new default instance.
*/
public RegionSelectionHandler() {
this(DEFAULT_OUTLINE_STROKE, Color.ORANGE,
new Color(255, 0, 255, 50));
}
/**
* Creates a new selection handler with the specified attributes.
*
* @param outlineStroke the outline stroke (<code>null</code> permitted).
* @param outlinePaint the outline paint (<code>null</code> permitted).
* @param fillPaint the fill paint (<code>null</code> permitted).
*/
public RegionSelectionHandler(Stroke outlineStroke, Paint outlinePaint,
Paint fillPaint) {
super();
this.outlineStroke = outlineStroke;
this.outlinePaint = outlinePaint;
this.fillPaint = fillPaint;
}
/**
* Creates a new instance with a modifier restriction.
*
* @param modifier e.g. shift has to be pressed InputEvents.SHIFT_MASK
*/
public RegionSelectionHandler(int modifier) {
super(modifier);
}
/**
* Returns the fill paint.
*
* @return The fill paint (possibly <code>null</code>).
*
* @see #setFillPaint(java.awt.Paint)
*/
public Paint getFillPaint() {
return fillPaint;
}
/**
* Sets the fill paint.
*
* @param fillPaint the fill paint (<code>null</code> permitted).
*
* @see #getFillPaint()
*/
public void setFillPaint(Paint fillPaint) {
this.fillPaint = fillPaint;
}
/**
* Returns the outline paint.
*
* @return The outline paint (possibly <code>null</code>).
*/
public Paint getOutlinePaint() {
return outlinePaint;
}
/**
* Sets the outline paint.
*
* @param outlinePaint the paint (<code>null</code> permitted).
*/
public void setOutlinePaint(Paint outlinePaint) {
this.outlinePaint = outlinePaint;
}
/**
* Returns the outline stroke.
*
* @return The outline stroke (possibly <code>null</code>).
*/
public Stroke getOutlineStroke() {
return outlineStroke;
}
/**
* Sets the outline stroke.
*
* @param outlineStroke the outline stroke (<code>null</code> permitted).
*/
public void setOutlineStroke(Stroke outlineStroke) {
this.outlineStroke = outlineStroke;
}
/**
* Handles a mouse pressed event.
*
* @param e the event.
*/
@Override
public abstract void mousePressed(MouseEvent e);
/**
* Handles a mouse dragged event.
*
* @param e the event.
*/
@Override
public abstract void mouseDragged(MouseEvent e);
/**
* Handles a mouse released event.
*
* @param e the event.
*/
@Override
public abstract void mouseReleased(MouseEvent e);
public boolean isLiveHandler() {
// FIXME: is this always true?
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.writePaint(this.fillPaint, 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.outlinePaint = SerialUtilities.readPaint(stream);
this.fillPaint = SerialUtilities.readPaint(stream);
this.outlineStroke = SerialUtilities.readStroke(stream);
}
}
| 6,686 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
RectangularRegionSelectionHandler.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/main/java/org/jfree/chart/panel/selectionhandler/RectangularRegionSelectionHandler.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2013, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* 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.]
*
* --------------------------------------
* RectangularRegionSelectionHandler.java
* --------------------------------------
* (C) Copyright 2009-2013, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): Michael Zinsmaier;
*
* Changes:
* --------
* 19-Jun-2009 : Version 1 (DG);
*
*/
package org.jfree.chart.panel.selectionhandler;
import java.awt.Paint;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.Stroke;
import java.awt.event.MouseEvent;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.util.ShapeUtilities;
/**
* A mouse handler that allows data items to be selected. The selection shape
* is a rectangle that can be expanded by dragging the mouse away from the starting
* point.
*
* Will only work together with a ChartPanel as event source
* @author zinsmaie
*/
public class RectangularRegionSelectionHandler extends RegionSelectionHandler {
/** a generated serial id. */
private static final long serialVersionUID = -8496935828054326324L;
/**
* The selection rectangle (in Java2D space).
*/
private Rectangle selectionRect;
/**
* The last mouse point.
*/
private Point2D startPoint;
/**
* Creates a new default instance.
*/
public RectangularRegionSelectionHandler() {
super();
this.selectionRect = null;
this.startPoint = null;
}
/**
* Creates a new instance with a modifier restriction
* @param modifier e.g. shift has to be pressed InputEvents.SHIFT_MASK
*/
public RectangularRegionSelectionHandler(int modifier) {
super(modifier);
this.selectionRect = null;
this.startPoint = null;
}
/**
* Creates a new selection handler with the specified attributes.
*
* @param outlineStroke the outline stroke.
* @param outlinePaint the outline paint.
* @param fillPaint the fill paint.
*/
public RectangularRegionSelectionHandler(Stroke outlineStroke,
Paint outlinePaint, Paint fillPaint) {
super(outlineStroke, outlinePaint, fillPaint);
this.selectionRect = null;
this.startPoint = null;
}
/**
* starts the rectangle selection by fixing the left upper corner of the rectangle
*
* @param e the event.
*/
public void mousePressed(MouseEvent e) {
if (!(e.getSource() instanceof ChartPanel)) {
return;
}
ChartPanel panel = (ChartPanel) e.getSource();
Rectangle2D dataArea = panel.getScreenDataArea();
if (dataArea.contains(e.getPoint())) {
SelectionManager selectionManager = panel.getSelectionManager();
if (selectionManager != null) {
if (!e.isShiftDown()) {
selectionManager.clearSelection();
}
Point pt = e.getPoint();
this.startPoint = new Point(pt);
this.selectionRect = new Rectangle(pt.x, pt.y, 1, 1);
}
}
}
/**
* adjusts with and height of the rectangle by expanding it to the actual
* position
*
* @param e the event.
*/
public void mouseDragged(MouseEvent e) {
ChartPanel panel = (ChartPanel) e.getSource();
if (this.startPoint == null) {
panel.clearLiveMouseHandler();
return; // we never started a selection
}
Point pt = e.getPoint();
Point2D pt2 = ShapeUtilities.getPointInRectangle(pt.x, pt.y,
panel.getScreenDataArea());
selectionRect = getRect(startPoint, pt2);
panel.setSelectionShape(selectionRect);
panel.setSelectionFillPaint(this.fillPaint);
panel.setSelectionOutlinePaint(this.outlinePaint);
panel.repaint();
}
/**
* finishes the selection and calls the {@link SelectionManager} of
* the event source. The SelectionManager is then responsible for the processing
* of the geometric selection.
*/
public void mouseReleased(MouseEvent e) {
ChartPanel panel = (ChartPanel) e.getSource();
if (this.startPoint == null) {
panel.clearLiveMouseHandler();
return; // we never started a selection
}
SelectionManager selectionManager = panel.getSelectionManager();
// do something with the selection shape
if (selectionManager != null) {
selectionManager.select(selectionRect);
}
panel.setSelectionShape(null);
this.selectionRect = null;
this.startPoint = null;
panel.repaint();
panel.clearLiveMouseHandler();
}
/**
* creates a rectangle from two points
* @param p1 one corner point
* @param p2 the other corner point
* @return a new rectangle that has both points in opposite corners
*/
private Rectangle getRect(Point2D p1, Point2D p2) {
int minX, minY;
int w, h;
// process x and w
if (p1.getX() < p2.getX()) {
minX = (int) p1.getX();
w = (int) p2.getX() - minX;
} else {
minX = (int) p2.getX();
w = (int) p1.getX() - minX;
if (w <= 0) {
w = 1;
}
}
// process y and h
if (p1.getY() < p2.getY()) {
minY = (int) p1.getY();
h = (int) p2.getY() - minY;
} else {
minY = (int) p2.getY();
h = (int) p1.getY() - minY;
if (h <= 0) {
h = 1;
}
}
return new Rectangle(minX, minY, w, h);
}
}
| 6,991 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
SelectionManager.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/main/java/org/jfree/chart/panel/selectionhandler/SelectionManager.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2013, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* 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.]
*
* ---------------------
* SelectionManager.java
* ---------------------
* (C) Copyright 2013, by Michael Zinsmaier and Contributors.
*
* Original Author: Michael Zinsmaier;
* Contributor(s): David Gilbert (for Object Refinery Limited);
*
* Changes:
* --------
* 17-Sep-2013 : Version 1 from MZ (DG);
*
*/
package org.jfree.chart.panel.selectionhandler;
import java.awt.geom.GeneralPath;
import java.awt.geom.Rectangle2D;
import java.io.Serializable;
/**
* Provides methods to handle data item selection based on a selection region
* or a selection point and to clear the current selection.
*
* @author zinsmaie
*/
public interface SelectionManager extends Serializable {
/**
* selects the data item at the point x,y
* @param x
* @param y
*/
public void select(double x, double y);
/**
* @param selection a rectangular selection area
*/
public void select(Rectangle2D selection);
/**
* @param selection free defined selection area
*/
public void select(GeneralPath selection);
/**
* clear the current selection (deselect all)
*/
public void clearSelection();
}
| 2,387 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
CircularRegionSelectionHandler.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/main/java/org/jfree/chart/panel/selectionhandler/CircularRegionSelectionHandler.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2013, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* 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.]
*
* -----------------------------------
* CircularRegionSelectionHandler.java
* -----------------------------------
* (C) Copyright 2013, by Michael Zinsmaier and Contributors.
*
* Original Author: Michael Zinsmaier;
* Contributor(s): David Gilbert (for Object Refinery Limited);
*
* Changes:
* --------
* 17-Sep-2013 : Version 1 from MZ (DG);
* 18-Sep-2013 : Allow circle to grow beyound plot bounds, but crop the
* selection region (DG);
*
*/
package org.jfree.chart.panel.selectionhandler;
import java.awt.Paint;
import java.awt.Point;
import java.awt.Stroke;
import java.awt.event.MouseEvent;
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 org.jfree.chart.ChartPanel;
/**
* A mouse handler that allows data items to be selected. The selection shape
* is a circle that can be expanded by dragging the mouse away from the starting
* point. Will only work together with a <code>ChartPanel</code> as the event
* source.
*
* @author zinsmaie
*/
public class CircularRegionSelectionHandler extends RegionSelectionHandler {
/** A generated serial id. */
private static final long serialVersionUID = 5627320657050195767L;
/**
* The selection path (in Java2D space).
*/
private Ellipse2D selectionCircle;
/**
* The start mouse point.
*/
private Point2D startPoint;
/**
* Creates a new default instance.
*/
public CircularRegionSelectionHandler() {
super();
this.selectionCircle = null;
this.startPoint = null;
}
/**
* Creates a new instance with a modifier restriction.
*
* @param modifier the modifier (for example, shift has to be pressed
* InputEvents.SHIFT_MASK).
*/
public CircularRegionSelectionHandler(int modifier) {
super(modifier);
this.selectionCircle = null;
this.startPoint = null;
}
/**
* Creates a new selection handler with the specified attributes.
*
* @param outlineStroke the outline stroke.
* @param outlinePaint the outline paint.
* @param fillPaint the fill paint.
*/
public CircularRegionSelectionHandler(Stroke outlineStroke,
Paint outlinePaint, Paint fillPaint) {
super(outlineStroke, outlinePaint, fillPaint);
this.selectionCircle = null;
this.startPoint = null;
}
/**
* Starts the circle selection by fixing the center of the circle.
*
* @param e the event.
*/
public void mousePressed(MouseEvent e) {
if (!(e.getSource() instanceof ChartPanel)) {
return;
}
ChartPanel panel = (ChartPanel) e.getSource();
Rectangle2D dataArea = panel.getScreenDataArea();
if (dataArea.contains(e.getPoint())) {
SelectionManager selectionManager = panel.getSelectionManager();
if (selectionManager != null) {
if (!e.isShiftDown()) {
selectionManager.clearSelection();
}
Point pt = e.getPoint();
this.startPoint = new Point(pt);
this.selectionCircle = new Ellipse2D.Double(pt.x, pt.y, 1, 1);
}
}
}
/**
* Adjusts the radius of the circle according to the actual mouse position.
*
* @param e the event.
*/
public void mouseDragged(MouseEvent e) {
ChartPanel panel = (ChartPanel) e.getSource();
if (this.startPoint == null) {
panel.clearLiveMouseHandler();
return; // we never started a selection
}
Point pt2 = e.getPoint();
double r = this.startPoint.distance(pt2);
if (r <= 0) {
r = 1.0;
}
this.selectionCircle = new Ellipse2D.Double(this.startPoint.getX() - r,
this.startPoint.getY() - r, 2.0 * r, 2.0 * r);
Area selectionArea = new Area(this.selectionCircle);
selectionArea.intersect(new Area(panel.getScreenDataArea()));
panel.setSelectionShape(selectionArea);
panel.setSelectionFillPaint(this.fillPaint);
panel.setSelectionOutlinePaint(this.outlinePaint);
panel.setSelectionOutlineStroke(this.outlineStroke);
panel.repaint();
}
/**
* Finishes the selection and calls the {@link SelectionManager} of
* the event source. The SelectionManager is then responsible for the
* processing of the geometric selection.
*
* @param event the event.
*/
public void mouseReleased(MouseEvent e) {
ChartPanel panel = (ChartPanel) e.getSource();
if (this.startPoint == null) {
panel.clearLiveMouseHandler();
return; // we never started a selection
}
SelectionManager selectionManager = panel.getSelectionManager();
// do something with the selection shape
if (selectionManager != null) {
selectionManager.select(new GeneralPath(this.selectionCircle));
}
panel.setSelectionShape(null);
this.selectionCircle = null;
this.startPoint = null;
panel.repaint();
panel.clearLiveMouseHandler();
}
}
| 6,527 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
RectangularHeightRegionSelectionHandler.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/main/java/org/jfree/chart/panel/selectionhandler/RectangularHeightRegionSelectionHandler.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2013, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* 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.]
*
* --------------------------------------
* RectangularRegionSelectionHandler.java
* --------------------------------------
* (C) Copyright 2009-2013, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): Michael Zinsmaier;
*
* Changes:
* --------
* 19-Jun-2009 : Version 1 (DG);
*
*/
package org.jfree.chart.panel.selectionhandler;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.util.ShapeUtilities;
import java.awt.*;
import java.awt.event.MouseEvent;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
/**
* A mouse handler that allows data items to be selected. The selection shape
* is a rectangle that can be expanded by dragging the mouse away from the starting
* point.
*
* Will only work together with a ChartPanel as event source
* @author zinsmaie
*/
public class RectangularHeightRegionSelectionHandler extends RegionSelectionHandler {
/** a generated serial id. */
private static final long serialVersionUID = -8496935828054326324L;
/**
* The selection rectangle (in Java2D space).
*/
private Rectangle selectionRect;
public Point2D getStartPoint() {
return startPoint;
}
/**
* The last mouse point.
*/
private Point2D startPoint;
/**
* Creates a new default instance.
*/
public RectangularHeightRegionSelectionHandler() {
super();
this.selectionRect = null;
this.startPoint = null;
}
/**
* Creates a new instance with a modifier restriction
* @param modifier e.g. shift has to be pressed InputEvents.SHIFT_MASK
*/
public RectangularHeightRegionSelectionHandler(int modifier) {
super(modifier);
this.selectionRect = null;
this.startPoint = null;
}
/**
* Creates a new selection handler with the specified attributes.
*
* @param outlineStroke the outline stroke.
* @param outlinePaint the outline paint.
* @param fillPaint the fill paint.
*/
public RectangularHeightRegionSelectionHandler(Stroke outlineStroke,
Paint outlinePaint, Paint fillPaint) {
super(outlineStroke, outlinePaint, fillPaint);
this.selectionRect = null;
this.startPoint = null;
}
/**
* starts the rectangle selection by fixing the left upper corner of the rectangle
*
* @param e the event.
*/
public void mousePressed(MouseEvent e) {
if (!(e.getSource() instanceof ChartPanel)) {
return;
}
ChartPanel panel = (ChartPanel) e.getSource();
Rectangle2D dataArea = panel.getScreenDataArea();
if (dataArea.contains(e.getPoint())) {
SelectionManager selectionManager = panel.getSelectionManager();
if (selectionManager != null) {
if (!e.isShiftDown()) {
selectionManager.clearSelection();
}
Point pt = e.getPoint();
this.startPoint = new Point(pt);
this.selectionRect = new Rectangle(pt.x, pt.y, 1, 1);
}
}
}
/**
* adjusts with and height of the rectangle by expanding it to the actual
* position
*
* @param e the event.
*/
public void mouseDragged(MouseEvent e) {
ChartPanel panel = (ChartPanel) e.getSource();
if (this.startPoint == null) {
panel.clearLiveMouseHandler();
return; // we never started a selection
}
Point pt = e.getPoint();
Point2D pt2 = ShapeUtilities.getPointInRectangle(pt.x, pt.y,
panel.getScreenDataArea());
selectionRect = getRect(startPoint, pt2, panel.getScreenDataArea());
panel.setSelectionShape(selectionRect);
panel.setSelectionFillPaint(this.fillPaint);
panel.setSelectionOutlinePaint(this.outlinePaint);
panel.repaint();
}
/**
* finishes the selection and calls the {@link org.jfree.chart.panel.selectionhandler.SelectionManager} of
* the event source. The SelectionManager is then responsible for the processing
* of the geometric selection.
*/
public void mouseReleased(MouseEvent e) {
ChartPanel panel = (ChartPanel) e.getSource();
if (this.startPoint == null) {
panel.clearLiveMouseHandler();
return; // we never started a selection
}
SelectionManager selectionManager = panel.getSelectionManager();
// do something with the selection shape
if (selectionManager != null) {
selectionManager.select(selectionRect);
}
//panel.setSelectionShape(null);
this.selectionRect = null;
//this.startPoint = null;
panel.repaint();
panel.clearLiveMouseHandler();
}
public Rectangle2D getRectangle2D(){
return this.selectionRect;
}
/**
* creates a rectangle from two points
*
* @param p1 one corner point
* @param p2 the other corner point
* @param plotarea the data area of the chart panel
* @return a new rectangle that has both points in opposite corners
*/
public Rectangle getRect(Point2D p1, Point2D p2, Rectangle2D plotarea ) {
int minX, minY;
int w, h;
// process x and w
if (p1.getX() < p2.getX()) {
minX = (int) p1.getX();
w = (int) p2.getX() - minX;
} else {
minX = (int) p2.getX();
w = (int) p1.getX() - minX;
if (w <= 0) {
w = 1;
}
}
// process y and h
minY = (int) plotarea.getMinY();
h = (int) plotarea.getHeight();
return new Rectangle(minX, minY, w, h);
}
}
| 7,078 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
PlotEntity.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/main/java/org/jfree/chart/entity/PlotEntity.java | /* ===========================================================
* 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.]
*
* ---------------
* PlotEntity.java
* ---------------
* (C) Copyright 2009-2012, by Object Refinery Limited and Contributors.
*
* Original Author: Peter Kolb;
* Contributor(s): ;
*
* Changes:
* --------
* 15-Feb-2009 : Version 1 (PK);
* 17-Jun-2012 : Removed JCommon dependencies (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.util.ObjectUtilities;
import org.jfree.chart.plot.Plot;
import org.jfree.chart.util.SerialUtilities;
/**
* 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 (<code>null</code> not permitted).
* @param plot the plot (<code>null</code> not permitted).
*/
public PlotEntity(Shape area, Plot plot) {
// defer argument checks...
this(area, plot, null);
}
/**
* Creates a new plot entity.
*
* @param area the area (<code>null</code> not permitted).
* @param plot the plot (<code>null</code> not permitted).
* @param toolTipText the tool tip text (<code>null</code> 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 (<code>null</code> not permitted).
* @param plot the plot (<code>null</code> not permitted).
* @param toolTipText the tool tip text (<code>null</code> permitted).
* @param urlText the URL text for HTML image maps (<code>null</code>
* permitted).
*/
public PlotEntity(Shape area, Plot plot, String toolTipText,
String urlText) {
super(area, toolTipText, urlText);
if (plot == null) {
throw new IllegalArgumentException("Null 'plot' argument.");
}
this.plot = plot;
}
/**
* Returns the plot that occupies the entity area.
*
* @return The plot (never <code>null</code>).
*/
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 buf = new StringBuilder("PlotEntity: ");
buf.append("tooltip = ");
buf.append(getToolTipText());
return buf.toString();
}
/**
* Tests the entity for equality with an arbitrary object.
*
* @param obj the object to test against (<code>null</code> 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));
}
}
| 6,348 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
package-info.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/main/java/org/jfree/chart/entity/package-info.java | /**
* Classes representing components of (or entities in) a chart.
*/
package org.jfree.chart.entity;
| 104 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
AxisEntity.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/main/java/org/jfree/chart/entity/AxisEntity.java | /* ===========================================================
* 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.]
*
* ----------------
* AxisEntity.java
* ----------------
* (C) Copyright 2009-2012, by Object Refinery Limited and Contributors.
*
* Original Author: Peter Kolb;
* Contributor(s): ;
*
* Changes:
* --------
* 15-Feb-2009 : Version 1 (PK);
* 16-Jun-2012 : Removed JCommon dependencies (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.ObjectUtilities;
import org.jfree.chart.util.SerialUtilities;
/**
* A class that captures information about an Axis of 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 (<code>null</code> not permitted).
* @param axis the axis (<code>null</code> not permitted).
*/
public AxisEntity(Shape area, Axis axis) {
// defer argument checks...
this(area, axis, null);
}
/**
* Creates a new axis entity.
*
* @param area the area (<code>null</code> not permitted).
* @param axis the axis (<code>null</code> not permitted).
* @param toolTipText the tool tip text (<code>null</code> 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 (<code>null</code> not permitted).
* @param axis the axis (<code>null</code> not permitted).
* @param toolTipText the tool tip text (<code>null</code> permitted).
* @param urlText the URL text for HTML image maps (<code>null</code>
* permitted).
*/
public AxisEntity(Shape area, Axis axis, String toolTipText,
String urlText) {
super(area, toolTipText, urlText);
if (axis == null) {
throw new IllegalArgumentException("Null 'axis' argument.");
}
this.axis = axis;
}
/**
* Returns the axis that occupies the entity area.
*
* @return The axis (never <code>null</code>).
*/
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 buf = new StringBuilder("AxisEntity: ");
buf.append("tooltip = ");
buf.append(getToolTipText());
return buf.toString();
}
/**
* Tests the entity for equality with an arbitrary object.
*
* @param obj the object to test against (<code>null</code> 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));
}
} | 6,382 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
LegendItemEntity.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/main/java/org/jfree/chart/entity/LegendItemEntity.java | /* ===========================================================
* 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.]
*
* ---------------------
* LegendItemEntity.java
* ---------------------
* (C) Copyright 2003-2012, 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);
* 17-Jun-2012 : Removed JCommon dependencies (DG);
*
*/
package org.jfree.chart.entity;
import java.awt.Shape;
import java.io.Serializable;
import org.jfree.chart.util.ObjectUtilities;
import org.jfree.data.general.Dataset;
/**
* 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;
}
/**
* Tests this object for equality with an arbitrary object.
*
* @param obj the object (<code>null</code> 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 <code>null</code>).
*/
@Override
public String toString() {
return "LegendItemEntity: seriesKey=" + this.seriesKey
+ ", dataset=" + this.dataset;
}
}
| 5,125 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
DataItemEntity.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/main/java/org/jfree/chart/entity/DataItemEntity.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2013, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* -------------------
* DataItemEntity.java
* -------------------
* (C) Copyright 2013, by Object Refinery Limited and Contributors.
*
* Original Author: ;
* Contributor(s): David Gilbert (for Object Refinery Limited);
*
* Changes:
* --------
* 17-Sep-2017 : Version 1 from MZ (DG);
*/
package org.jfree.chart.entity;
import java.awt.Shape;
import org.jfree.data.extension.DatasetCursor;
import org.jfree.data.general.Dataset;
/**
* Super class of all entities, that encapsulate the shapes and meta
* information of rendered data items.
*
* @author zinsmaie
*/
public abstract class DataItemEntity extends ChartEntity {
private static final long serialVersionUID = -3785048574533713069L;
/**
* Creates a new chart entity.
*
* @param area the area (<code>null</code> not permitted).
*/
public DataItemEntity(Shape area) {
super(area);
}
/**
* Creates a new chart entity.
*
* @param area the area (<code>null</code> not permitted).
* @param toolTipText the tool tip text (<code>null</code> permitted).
*/
public DataItemEntity(Shape area, String toolTipText) {
super(area, toolTipText, null);
}
/**
* Creates a new entity.
*
* @param area the area (<code>null</code> not permitted).
* @param toolTipText the tool tip text (<code>null</code> permitted).
* @param urlText the URL text for HTML image maps (<code>null</code>
* permitted).
*/
public DataItemEntity(Shape area, String toolTipText, String urlText) {
super(area, toolTipText, urlText);
}
/**
* Returns the dataset this entity refers to. This can be used to
* differentiate between items in a chart that displays more than one
* dataset.<br>
* Uses the general dataset interface to as return value
*
* @return The dataset (never <code>null</code>).
*
*/
public abstract Dataset getGeneralDataset();
/**
* @return a new instance of a {@link DatasetCursor} which points to the
* DataItem
*/
public abstract DatasetCursor getItemCursor();
}
| 3,398 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
CategoryLabelEntity.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/main/java/org/jfree/chart/entity/CategoryLabelEntity.java | /* ===========================================================
* 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.]
*
* ------------------------
* CategoryLabelEntity.java
* ------------------------
* (C) Copyright 2006-2012, 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);
* 17-Jun-2012 : Removed JCommon dependencies (DG);
*
*/
package org.jfree.chart.entity;
import java.awt.Shape;
import org.jfree.chart.HashUtilities;
import org.jfree.chart.axis.CategoryAxis;
import org.jfree.chart.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 (<code>null</code> 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 buf = new StringBuilder("CategoryLabelEntity: ");
buf.append("category=");
buf.append(this.key);
buf.append(", tooltip=").append(getToolTipText());
buf.append(", url=").append(getURLText());
return buf.toString();
}
}
| 3,950 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
StandardEntityCollection.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/main/java/org/jfree/chart/entity/StandardEntityCollection.java | /* ===========================================================
* 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.]
*
* -----------------------------
* StandardEntityCollection.java
* -----------------------------
* (C) Copyright 2001-2012, 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);
* 17-Jun-2012 : Removed JCommon dependencies (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.ObjectUtilities;
import org.jfree.chart.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<ChartEntity> entities;
/**
* Constructs a new entity collection (initially empty).
*/
public StandardEntityCollection() {
this.entities = new java.util.ArrayList<ChartEntity>();
}
/**
* 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 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 (<code>null</code> not permitted).
*/
@Override
public void add(ChartEntity entity) {
if (entity == null) {
throw new IllegalArgumentException("Null 'entity' argument.");
}
this.entities.add(entity);
}
/**
* Adds all the entities from the specified collection.
*
* @param collection the collection of entities (<code>null</code> 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 <code>null</code> if there is no such entity.
*
* @param x the x coordinate.
* @param y the y coordinate.
*
* @return The entity (possibly <code>null</code>).
*/
@Override
public ChartEntity getEntity(double x, double y) {
int entityCount = this.entities.size();
for (int i = entityCount - 1; i >= 0; i--) {
ChartEntity entity = 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<ChartEntity> getEntities() {
return Collections.unmodifiableCollection(this.entities);
}
/**
* Returns an iterator for the entities in the collection.
*
* @return An iterator.
*/
@Override
public Iterator<ChartEntity> iterator() {
return this.entities.iterator();
}
/**
* Tests this object for equality with an arbitrary object.
*
* @param obj the object to test against (<code>null</code> 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<ChartEntity>(this.entities.size());
for (int i = 0; i < this.entities.size(); i++) {
ChartEntity entity = this.entities.get(i);
clone.entities.add((ChartEntity) entity.clone());
}
return clone;
}
}
| 6,620 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
XYItemEntity.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/main/java/org/jfree/chart/entity/XYItemEntity.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2013, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 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-2013, 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.extension.DatasetCursor;
import org.jfree.data.extension.impl.XYCursor;
import org.jfree.data.general.Dataset;
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 DataItemEntity {
/** 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;
}
/**
* @see DataItemEntity#getGeneralDataset()
*/
public Dataset getGeneralDataset() {
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 (<code>null</code> 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();
}
@Override
public DatasetCursor getItemCursor() {
return new XYCursor(series, item);
}
}
| 5,607 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
CategoryItemEntity.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/main/java/org/jfree/chart/entity/CategoryItemEntity.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2013, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 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);
* 17-Jun-2012 : Removed JCommon dependencies (DG);
*
*/
package org.jfree.chart.entity;
import java.awt.Shape;
import java.io.Serializable;
import org.jfree.chart.util.ObjectUtilities;
import org.jfree.data.category.CategoryDataset;
import org.jfree.data.extension.DatasetCursor;
import org.jfree.data.extension.impl.CategoryCursor;
import org.jfree.data.general.Dataset;
/**
* A chart entity that represents one item within a category plot.
*/
public class CategoryItemEntity extends DataItemEntity
implements Cloneable, Serializable {
/** For serialization. */
private static final long serialVersionUID = -8657249457902337349L;
/** The dataset. */
private CategoryDataset dataset;
/**
* The row key.
*
* @since 1.0.6
*/
private Comparable rowKey;
/**
* The column key.
*
* @since 1.0.6
*/
private Comparable columnKey;
/**
* Creates a new entity instance for an item in the specified dataset.
*
* @param area the 'hotspot' area (<code>null</code> not permitted).
* @param toolTipText the tool tip text.
* @param urlText the URL text.
* @param dataset the dataset (<code>null</code> not permitted).
* @param rowKey the row key (<code>null</code> not permitted).
* @param columnKey the column key (<code>null</code> not permitted).
*
* @since 1.0.6
*/
public CategoryItemEntity(Shape area, String toolTipText, String urlText,
CategoryDataset dataset, Comparable rowKey, Comparable columnKey) {
super(area, toolTipText, urlText);
if (dataset == null) {
throw new IllegalArgumentException("Null 'dataset' argument.");
}
this.dataset = dataset;
this.rowKey = rowKey;
this.columnKey = 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 <code>null</code>).
*
* @see #setDataset(CategoryDataset)
*/
public CategoryDataset getDataset() {
return this.dataset;
}
/**
* @see DataItemEntity#getGeneralDataset()
*/
public Dataset getGeneralDataset() {
return this.dataset;
}
/**
* Sets the dataset this entity refers to.
*
* @param dataset the dataset (<code>null</code> not permitted).
*
* @see #getDataset()
*/
public void setDataset(CategoryDataset dataset) {
if (dataset == null) {
throw new IllegalArgumentException("Null 'dataset' argument.");
}
this.dataset = dataset;
}
/**
* Returns the row key.
*
* @return The row key (never <code>null</code>).
*
* @since 1.0.6
*
* @see #setRowKey(Comparable)
*/
public Comparable getRowKey() {
return this.rowKey;
}
/**
* Sets the row key.
*
* @param rowKey the row key (<code>null</code> not permitted).
*
* @since 1.0.6
*
* @see #getRowKey()
*/
public void setRowKey(Comparable rowKey) {
this.rowKey = rowKey;
}
/**
* Returns the column key.
*
* @return The column key (never <code>null</code>).
*
* @since 1.0.6
*
* @see #setColumnKey(Comparable)
*/
public Comparable getColumnKey() {
return this.columnKey;
}
/**
* Sets the column key.
*
* @param columnKey the column key (<code>null</code> not permitted).
*
* @since 1.0.6
*
* @see #getColumnKey()
*/
public void setColumnKey(Comparable columnKey) {
this.columnKey = columnKey;
}
/**
* Returns a string representing this object (useful for debugging
* purposes).
*
* @return A string (never <code>null</code>).
*/
@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 (<code>null</code> 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;
}
return super.equals(obj);
}
@Override
public DatasetCursor getItemCursor() {
//category item entities are not yet typed
return new CategoryCursor(rowKey, columnKey);
}
}
| 7,351 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
JFreeChartEntity.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/main/java/org/jfree/chart/entity/JFreeChartEntity.java | /* ===========================================================
* 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.]
*
* ---------------------
* JFreeChartEntity.java
* --------------------
* (C) Copyright 2009-2012, by Object Refinery Limited and Contributors.
*
* Original Author: Peter Kolb;
* Contributor(s): ;
*
* Changes:
* --------
* 15-Feb-2009 : Version 1 (PK);
* 17-Jun-2012 : Removed JCommon dependencies (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.JFreeChart;
import org.jfree.chart.util.ObjectUtilities;
import org.jfree.chart.util.SerialUtilities;
/**
* 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 (<code>null</code> not permitted).
* @param chart the chart (<code>null</code> not permitted).
*/
public JFreeChartEntity(Shape area, JFreeChart chart) {
// defer argument checks...
this(area, chart, null);
}
/**
* Creates a new chart entity.
*
* @param area the area (<code>null</code> not permitted).
* @param chart the chart (<code>null</code> not permitted).
* @param toolTipText the tool tip text (<code>null</code> 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 (<code>null</code> not permitted).
* @param chart the chart (<code>null</code> not permitted).
* @param toolTipText the tool tip text (<code>null</code> permitted).
* @param urlText the URL text for HTML image maps (<code>null</code>
* permitted).
*/
public JFreeChartEntity(Shape area, JFreeChart chart, String toolTipText,
String urlText) {
super(area, toolTipText, urlText);
if (chart == null) {
throw new IllegalArgumentException("Null 'chart' argument.");
}
this.chart = chart;
}
/**
* Returns the chart that occupies the entity area.
*
* @return The chart (never <code>null</code>).
*/
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 buf = new StringBuilder("JFreeChartEntity: ");
buf.append("tooltip = ");
buf.append(getToolTipText());
return buf.toString();
}
/**
* Tests the entity for equality with an arbitrary object.
*
* @param obj the object to test against (<code>null</code> 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));
}
}
| 6,476 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
ChartEntity.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/main/java/org/jfree/chart/entity/ChartEntity.java | /* ===========================================================
* 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.]
*
* ----------------
* ChartEntity.java
* ----------------
* (C) Copyright 2002-2012, 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);
* 16-Jun-2012 : Removed JCommon dependencies (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.util.ObjectUtilities;
import org.jfree.chart.util.PublicCloneable;
import org.jfree.chart.imagemap.ToolTipTagFragmentGenerator;
import org.jfree.chart.imagemap.URLTagFragmentGenerator;
import org.jfree.chart.util.SerialUtilities;
/**
* 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 (<code>null</code> not permitted).
*/
public ChartEntity(Shape area) {
// defer argument checks...
this(area, null);
}
/**
* Creates a new chart entity.
*
* @param area the area (<code>null</code> not permitted).
* @param toolTipText the tool tip text (<code>null</code> permitted).
*/
public ChartEntity(Shape area, String toolTipText) {
// defer argument checks...
this(area, toolTipText, null);
}
/**
* Creates a new entity.
*
* @param area the area (<code>null</code> not permitted).
* @param toolTipText the tool tip text (<code>null</code> permitted).
* @param urlText the URL text for HTML image maps (<code>null</code>
* permitted).
*/
public ChartEntity(Shape area, String toolTipText, String urlText) {
if (area == null) {
throw new IllegalArgumentException("Null 'area' argument.");
}
this.area = area;
this.toolTipText = toolTipText;
this.urlText = urlText;
}
/**
* Returns the area occupied by the entity (in Java 2D space).
*
* @return The area (never <code>null</code>).
*/
public Shape getArea() {
return this.area;
}
/**
* Sets the area for the entity.
* <P>
* 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 (<code>null</code> not permitted).
*/
public void setArea(Shape area) {
if (area == null) {
throw new IllegalArgumentException("Null 'area' argument.");
}
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 <code>null</code>).
*/
public String getToolTipText() {
return this.toolTipText;
}
/**
* Sets the tool tip text.
*
* @param text the text (<code>null</code> 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 <code>null</code>).
*/
public String getURLText() {
return this.urlText;
}
/**
* Sets the URL text.
*
* @param text the text (<code>null</code> 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 <code>null</code>).
*/
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 <code>null</code>).
*/
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 (<code>null</code> not permitted).
*
* @return Upper left and lower right corner of a rectangle.
*/
private String getRectCoords(Rectangle2D rectangle) {
if (rectangle == null) {
throw new IllegalArgumentException("Null 'rectangle' argument.");
}
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 (<code>null</code> not permitted).
*
* @return The coordinates for a given shape as string.
*/
private String getPolyCoords(Shape shape) {
if (shape == null) {
throw new IllegalArgumentException("Null 'shape' argument.");
}
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 <code>XHTML 1.0</code> compliant.
*
* @param toolTipTagFragmentGenerator a generator for the HTML fragment
* that will contain the tooltip text (<code>null</code> not permitted
* if this entity contains tooltip information).
* @param urlTagFragmentGenerator a generator for the HTML fragment that
* will contain the URL reference (<code>null</code> 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("<area shape=\"" + getShapeType() + "\"" + " coords=\""
+ getShapeCoords() + "\"");
if (hasToolTip) {
tag.append(toolTipTagFragmentGenerator.generateToolTipFragment(
this.toolTipText));
}
if (hasURL) {
tag.append(urlTagFragmentGenerator.generateURLFragment(
this.urlText));
}
else {
tag.append(" nohref=\"nohref\"");
}
// if there is a tool tip, we expect it to generate the title and
// alt values, so we only add an empty alt if there is no tooltip
if (!hasToolTip) {
tag.append(" alt=\"\"");
}
tag.append("/>");
}
return tag.toString();
}
/**
* Returns a string representation of the chart entity, useful for
* debugging.
*
* @return A string.
*/
@Override
public String toString() {
StringBuilder buf = new StringBuilder("ChartEntity: ");
buf.append("tooltip = ");
buf.append(this.toolTipText);
return buf.toString();
}
/**
* Tests the entity for equality with an arbitrary object.
*
* @param obj the object to test against (<code>null</code> 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);
}
}
| 14,963 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
XYAnnotationEntity.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/main/java/org/jfree/chart/entity/XYAnnotationEntity.java | /* ===========================================================
* 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.]
*
* -----------------------
* 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 (<code>null</code> 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;
}
}
| 3,470 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
TickLabelEntity.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/main/java/org/jfree/chart/entity/TickLabelEntity.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2011, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 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 (<code>null</code> not permitted).
* @param toolTipText the tool tip text (<code>null</code> permitted).
* @param urlText the URL text for HTML image maps (<code>null</code>
* permitted).
*/
public TickLabelEntity(Shape area, String toolTipText, String urlText) {
super(area, toolTipText, urlText);
}
}
| 2,348 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
TitleEntity.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/main/java/org/jfree/chart/entity/TitleEntity.java | /* ===========================================================
* 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.]
*
* ----------------
* TitleEntity.java
* ----------------
* (C) Copyright 2009-2012, by Object Refinery Limited and Contributors.
*
* Original Author: Peter Kolb;
* Contributor(s): ;
*
* Changes:
* --------
* 15-Feb-2009 : Version 1 (PK);
* 16-Jun-2012 : Removed JCommon dependencies (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.util.ObjectUtilities;
import org.jfree.chart.title.Title;
import org.jfree.chart.util.SerialUtilities;
/**
* 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 (<code>null</code> not permitted).
* @param title the title (<code>null</code> not permitted).
*/
public TitleEntity(Shape area, Title title) {
// defer argument checks...
this(area, title, null);
}
/**
* Creates a new chart entity.
*
* @param area the area (<code>null</code> not permitted).
* @param title the title (<code>null</code> not permitted).
* @param toolTipText the tool tip text (<code>null</code> 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 (<code>null</code> not permitted).
* @param title the title (<code>null</code> not permitted).
* @param toolTipText the tool tip text (<code>null</code> permitted).
* @param urlText the URL text for HTML image maps (<code>null</code>
* permitted).
*/
public TitleEntity(Shape area, Title title, String toolTipText,
String urlText) {
super(area, toolTipText, urlText);
if (title == null) {
throw new IllegalArgumentException("Null 'title' argument.");
}
this.title = title;
}
/**
* Returns the title that occupies the entity area.
*
* @return The title (never <code>null</code>).
*/
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 buf = new StringBuilder("TitleEntity: ");
buf.append("tooltip = ");
buf.append(getToolTipText());
return buf.toString();
}
/**
* Tests the entity for equality with an arbitrary object.
*
* @param obj the object to test against (<code>null</code> 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));
}
} | 6,413 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
PieSectionEntity.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/main/java/org/jfree/chart/entity/PieSectionEntity.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2013, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 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-2013, 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);
* 17-Jun-2012 : Removed JCommon dependencies (DG);
*
*/
package org.jfree.chart.entity;
import java.awt.Shape;
import java.io.Serializable;
import org.jfree.chart.HashUtilities;
import org.jfree.chart.util.ObjectUtilities;
import org.jfree.data.extension.DatasetCursor;
import org.jfree.data.extension.impl.PieCursor;
import org.jfree.data.general.Dataset;
import org.jfree.data.general.PieDataset;
/**
* A chart entity that represents one section within a pie plot.
*/
public class PieSectionEntity extends DataItemEntity
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;
}
/**
* @see DataItemEntity#getGeneralDataset()
*/
public Dataset getGeneralDataset() {
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 (<code>null</code> 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() + ")";
}
@Override
public DatasetCursor getItemCursor() {
//pie item entities are not yet typed
return new PieCursor(sectionKey);
}
}
| 7,748 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
EntityCollection.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/main/java/org/jfree/chart/entity/EntityCollection.java | /* ===========================================================
* 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.]
*
* ---------------------
* 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 extends Iterable<ChartEntity> {
/**
* Clears all entities.
*/
public void clear();
/**
* Adds an entity to the collection.
*
* @param entity the entity (<code>null</code> 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<ChartEntity> getEntities();
/**
* Returns an iterator for the entities in the collection.
*
* @return An iterator.
*/
public Iterator<ChartEntity> iterator();
}
| 3,501 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
LengthAdjustmentType.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/main/java/org/jfree/chart/ui/LengthAdjustmentType.java | /* ===========================================================
* 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.]
*
* -------------------------
* LengthAdjustmentType.java
* -------------------------
* (C) Copyright 2005-2012, by Object Refinery Limited.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* $Id: LengthAdjustmentType.java,v 1.5 2005/11/03 09:55:27 mungady Exp $
*
* Changes:
* --------
* 21-Jan-2005 : Version 1 (DG);
* 16-Jun-2012 : Moved from JCommon to JFreeChart (DG);
*
*/
package org.jfree.chart.ui;
/**
* Represents the three options for adjusting a length: expand, contract, and
* no change.
*/
public enum LengthAdjustmentType {
/** NO_CHANGE. */
NO_CHANGE("NO_CHANGE"),
/** EXPAND. */
EXPAND("EXPAND"),
/** CONTRACT. */
CONTRACT("CONTRACT");
/** The name. */
private String name;
/**
* Private constructor.
*
* @param name the name.
*/
private LengthAdjustmentType(final String name) {
this.name = name;
}
/**
* Returns a string representing the object.
*
* @return The string.
*/
@Override
public String toString() {
return this.name;
}
}
| 2,361 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
LCBLayout.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/main/java/org/jfree/chart/ui/LCBLayout.java | /* ========================================================================
* JCommon : a free general purpose class library for the Java(tm) platform
* ========================================================================
*
* (C) Copyright 2000-2005, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jcommon/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* 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.]
*
* --------------
* LCBLayout.java
* --------------
* (C) Copyright 2000-2005, by Object Refinery Limited.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* $Id: LCBLayout.java,v 1.5 2005/11/16 15:58:40 taqua Exp $
*
* Changes (from 26-Oct-2001)
* --------------------------
* 26-Oct-2001 : Changed package to com.jrefinery.layout.* (DG);
* 10-Oct-2002 : Fixed errors reported by Checkstyle (DG);
*/
package org.jfree.chart.ui;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Insets;
import java.awt.LayoutManager;
import java.io.Serializable;
/**
* Specialised layout manager for a grid of components.
*
* @author David Gilbert
*/
public class LCBLayout implements LayoutManager, Serializable {
/** For serialization. */
private static final long serialVersionUID = -2531780832406163833L;
/** A constant for the number of columns in the layout. */
private static final int COLUMNS = 3;
/** Tracks the column widths. */
private int[] colWidth;
/** Tracks the row heights. */
private int[] rowHeight;
/** The gap between each label and component. */
private int labelGap;
/** The gap between each component and button. */
private int buttonGap;
/** The gap between rows. */
private int vGap;
/**
* Creates a new LCBLayout with the specified maximum number of rows.
*
* @param maxrows the maximum number of rows.
*/
public LCBLayout(final int maxrows) {
this.labelGap = 10;
this.buttonGap = 6;
this.vGap = 2;
this.colWidth = new int[COLUMNS];
this.rowHeight = new int[maxrows];
}
/**
* Returns the preferred size using this layout manager.
*
* @param parent the parent.
*
* @return the preferred size using this layout manager.
*/
@Override
public Dimension preferredLayoutSize(final Container parent) {
synchronized (parent.getTreeLock()) {
final Insets insets = parent.getInsets();
final int ncomponents = parent.getComponentCount();
final int nrows = ncomponents / COLUMNS;
for (int c = 0; c < COLUMNS; c++) {
for (int r = 0; r < nrows; r++) {
final Component component
= parent.getComponent(r * COLUMNS + c);
final Dimension d = component.getPreferredSize();
if (this.colWidth[c] < d.width) {
this.colWidth[c] = d.width;
}
if (this.rowHeight[r] < d.height) {
this.rowHeight[r] = d.height;
}
}
}
int totalHeight = this.vGap * (nrows - 1);
for (int r = 0; r < nrows; r++) {
totalHeight = totalHeight + this.rowHeight[r];
}
final int totalWidth = this.colWidth[0] + this.labelGap
+ this.colWidth[1] + this.buttonGap + this.colWidth[2];
return new Dimension(
insets.left + insets.right + totalWidth + this.labelGap
+ this.buttonGap,
insets.top + insets.bottom + totalHeight + this.vGap
);
}
}
/**
* Returns the minimum size using this layout manager.
*
* @param parent the parent.
*
* @return the minimum size using this layout manager.
*/
@Override
public Dimension minimumLayoutSize(final Container parent) {
synchronized (parent.getTreeLock()) {
final Insets insets = parent.getInsets();
final int ncomponents = parent.getComponentCount();
final int nrows = ncomponents / COLUMNS;
for (int c = 0; c < COLUMNS; c++) {
for (int r = 0; r < nrows; r++) {
final Component component
= parent.getComponent(r * COLUMNS + c);
final Dimension d = component.getMinimumSize();
if (this.colWidth[c] < d.width) {
this.colWidth[c] = d.width;
}
if (this.rowHeight[r] < d.height) {
this.rowHeight[r] = d.height;
}
}
}
int totalHeight = this.vGap * (nrows - 1);
for (int r = 0; r < nrows; r++) {
totalHeight = totalHeight + this.rowHeight[r];
}
final int totalWidth = this.colWidth[0] + this.labelGap
+ this.colWidth[1] + this.buttonGap + this.colWidth[2];
return new Dimension(
insets.left + insets.right + totalWidth + this.labelGap
+ this.buttonGap,
insets.top + insets.bottom + totalHeight + this.vGap
);
}
}
/**
* Lays out the components.
*
* @param parent the parent.
*/
@Override
public void layoutContainer(final Container parent) {
synchronized (parent.getTreeLock()) {
final Insets insets = parent.getInsets();
final int ncomponents = parent.getComponentCount();
final int nrows = ncomponents / COLUMNS;
for (int c = 0; c < COLUMNS; c++) {
for (int r = 0; r < nrows; r++) {
final Component component
= parent.getComponent(r * COLUMNS + c);
final Dimension d = component.getPreferredSize();
if (this.colWidth[c] < d.width) {
this.colWidth[c] = d.width;
}
if (this.rowHeight[r] < d.height) {
this.rowHeight[r] = d.height;
}
}
}
int totalHeight = this.vGap * (nrows - 1);
for (int r = 0; r < nrows; r++) {
totalHeight = totalHeight + this.rowHeight[r];
}
final int totalWidth = this.colWidth[0] + this.colWidth[1]
+ this.colWidth[2];
// adjust the width of the second column to use up all of parent
final int available = parent.getWidth() - insets.left
- insets.right - this.labelGap - this.buttonGap;
this.colWidth[1] = this.colWidth[1] + (available - totalWidth);
// *** DO THE LAYOUT ***
int x = insets.left;
for (int c = 0; c < COLUMNS; c++) {
int y = insets.top;
for (int r = 0; r < nrows; r++) {
final int i = r * COLUMNS + c;
if (i < ncomponents) {
final Component component = parent.getComponent(i);
final Dimension d = component.getPreferredSize();
final int h = d.height;
final int adjust = (this.rowHeight[r] - h) / 2;
parent.getComponent(i).setBounds(x, y + adjust,
this.colWidth[c], h);
}
y = y + this.rowHeight[r] + this.vGap;
}
x = x + this.colWidth[c];
if (c == 0) {
x = x + this.labelGap;
}
if (c == 1) {
x = x + this.buttonGap;
}
}
}
}
/**
* Not used.
*
* @param comp the component.
*/
public void addLayoutComponent(final Component comp) {
// not used
}
/**
* Not used.
*
* @param comp the component.
*/
@Override
public void removeLayoutComponent(final Component comp) {
// not used
}
/**
* Not used.
*
* @param name the component name.
* @param comp the component.
*/
@Override
public void addLayoutComponent(final String name, final Component comp) {
// not used
}
/**
* Not used.
*
* @param name the component name.
* @param comp the component.
*/
public void removeLayoutComponent(final String name, final Component comp) {
// not used
}
}
| 9,598 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
NumberCellRenderer.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/main/java/org/jfree/chart/ui/NumberCellRenderer.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2013, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* -----------------------
* NumberCellRenderer.java
* -----------------------
* (C) Copyright 2000-2013, by Object Refinery Limited.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes (from 26-Oct-2001)
* --------------------------
* 26-Oct-2001 : Changed package to com.jrefinery.ui.*;
* 11-Mar-2002 : Updated import statements (DG);
* 17-Jun-2012 : Moved from JCommon to JFreeChart (DG);
*
*/
package org.jfree.chart.ui;
import java.awt.Component;
import java.text.NumberFormat;
import javax.swing.JTable;
import javax.swing.SwingConstants;
import javax.swing.table.DefaultTableCellRenderer;
/**
* A table cell renderer that formats numbers with right alignment in each cell.
*/
public class NumberCellRenderer extends DefaultTableCellRenderer {
private static final long serialVersionUID = 6141158525258247290L;
/**
* Default constructor - builds a renderer that right justifies the
* contents of a table cell.
*/
public NumberCellRenderer() {
super();
setHorizontalAlignment(SwingConstants.RIGHT);
}
/**
* Returns itself as the renderer. Supports the TableCellRenderer interface.
*
* @param table the table.
* @param value the data to be rendered.
* @param isSelected a boolean that indicates whether or not the cell is
* selected.
* @param hasFocus a boolean that indicates whether or not the cell has
* the focus.
* @param row the (zero-based) row index.
* @param column the (zero-based) column index.
*
* @return the component that can render the contents of the cell.
*/
@Override
public Component getTableCellRendererComponent(final JTable table,
final Object value, final boolean isSelected,
final boolean hasFocus, final int row, final int column) {
setFont(null);
final NumberFormat nf = NumberFormat.getNumberInstance();
if (value != null) {
setText(nf.format(value));
}
else {
setText("");
}
if (isSelected) {
setBackground(table.getSelectionBackground());
}
else {
setBackground(null);
}
return this;
}
}
| 3,545 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
RefineryUtilities.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/main/java/org/jfree/chart/ui/RefineryUtilities.java | /* ===========================================================
* 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.]
*
* ----------------------
* RefineryUtilities.java
* ----------------------
* (C) Copyright 2000-2012, by Object Refinery Limited.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): Jon Iles;
*
* Changes (from 26-Oct-2001)
* --------------------------
* 26-Oct-2001 : Changed package to com.jrefinery.ui.*;
* 26-Nov-2001 : Changed name to SwingRefinery.java to make it obvious that this is not part of
* the Java APIs (DG);
* 10-Dec-2001 : Changed name (again) to JRefineryUtilities.java (DG);
* 28-Feb-2002 : Moved system properties classes into com.jrefinery.ui.about (DG);
* 19-Apr-2002 : Renamed JRefineryUtilities-->RefineryUtilities. Added drawRotatedString()
* method (DG);
* 21-May-2002 : Changed frame positioning methods to accept Window parameters, as suggested by
* Laurence Vanhelsuwe (DG);
* 27-May-2002 : Added getPointInRectangle method (DG);
* 26-Jun-2002 : Removed unnecessary imports (DG);
* 12-Jul-2002 : Added workaround for rotated text (JI);
* 14-Oct-2002 : Fixed errors reported by Checkstyle (DG);
* 08-May-2003 : Added a new drawRotatedString() method (DG);
* 09-May-2003 : Added a drawRotatedShape() method (DG);
* 10-Jun-2003 : Updated aligned and rotated string methods (DG);
* 29-Oct-2003 : Added workaround for font alignment in PDF output (DG);
* 07-Nov-2003 : Added rotateShape() method (DG);
* 16-Mar-2004 : Moved rotateShape() method to ShapeUtils.java (DG);
* 07-Apr-2004 : Modified text bounds calculation with TextUtilities.getTextBounds() (DG);
* 21-May-2004 : Fixed bug 951870 - precision in drawAlignedString() method (DG);
* 30-Sep-2004 : Deprecated and moved a number of methods to the TextUtilities class (DG);
* 04-Oct-2004 : Renamed ShapeUtils --> ShapeUtilities (DG);
* 11-Jan-2005 : Removed deprecated code in preparation for the 1.0.0 release (DG);
* 16-Jun-2012 : Moved from JCommon to JFreeChart (DG);
*
*/
package org.jfree.chart.ui;
import javax.swing.*;
import java.awt.*;
/**
* A collection of utility methods relating to user interfaces.
*/
public class RefineryUtilities {
private RefineryUtilities() {
}
/**
* Positions the specified frame in the middle of the screen.
*
* @param frame the frame to be centered on the screen.
*/
public static void centerFrameOnScreen(final Window frame) {
positionFrameOnScreen(frame, 0.5, 0.5);
}
/**
* Positions the specified frame at a relative position in the screen, where 50% is considered
* to be the center of the screen.
*
* @param frame the frame.
* @param horizontalPercent the relative horizontal position of the frame (0.0 to 1.0,
* where 0.5 is the center of the screen).
* @param verticalPercent the relative vertical position of the frame (0.0 to 1.0, where
* 0.5 is the center of the screen).
*/
public static void positionFrameOnScreen(final Window frame,
final double horizontalPercent,
final double verticalPercent) {
final Rectangle s = frame.getGraphicsConfiguration().getBounds();
final Dimension f = frame.getSize();
final int w = Math.max(s.width - f.width, 0);
final int h = Math.max(s.height - f.height, 0);
final int x = (int) (horizontalPercent * w) + s.x;
final int y = (int) (verticalPercent * h) + s.y;
frame.setBounds(x, y, f.width, f.height);
}
/**
* Positions the specified frame at a random location on the screen while ensuring that the
* entire frame is visible (provided that the frame is smaller than the screen).
*
* @param frame the frame.
*/
public static void positionFrameRandomly(final Window frame) {
positionFrameOnScreen(frame, Math.random(), Math.random());
}
/**
* Positions the specified dialog within its parent.
*
* @param dialog the dialog to be positioned on the screen.
*/
public static void centerDialogInParent(final Dialog dialog) {
positionDialogRelativeToParent(dialog, 0.5, 0.5);
}
/**
* Positions the specified dialog at a position relative to its parent.
*
* @param dialog the dialog to be positioned.
* @param horizontalPercent the relative location.
* @param verticalPercent the relative location.
*/
public static void positionDialogRelativeToParent(final Dialog dialog,
final double horizontalPercent,
final double verticalPercent) {
final Container parent = dialog.getParent();
if (parent == null)
{
centerFrameOnScreen(dialog);
return;
}
final Dimension d = dialog.getSize();
final Dimension p = parent.getSize();
final int baseX = parent.getX();
final int baseY = parent.getY();
final int x = baseX + (int) (horizontalPercent * p.width);
final int y = baseY + (int) (verticalPercent * p.height);
// make sure the dialog fits completely on the screen...
final Rectangle s = parent.getGraphicsConfiguration().getBounds();
final Rectangle r = new Rectangle(x, y, d.width, d.height);
dialog.setBounds(r.intersection(s));
}
/**
* Creates a label with a specific font.
*
* @param text the text for the label.
* @param font the font.
*
* @return The label.
*/
public static JLabel createJLabel(final String text, final Font font) {
final JLabel result = new JLabel(text);
result.setFont(font);
return result;
}
/**
* Creates a label with a specific font and color.
*
* @param text the text for the label.
* @param font the font.
* @param color the color.
*
* @return The label.
*/
public static JLabel createJLabel(final String text, final Font font, final Color color) {
final JLabel result = new JLabel(text);
result.setFont(font);
result.setForeground(color);
return result;
}
/**
* Creates a {@link JButton}.
*
* @param label the label.
* @param font the font.
*
* @return The button.
*/
public static JButton createJButton(final String label, final Font font) {
final JButton result = new JButton(label);
result.setFont(font);
return result;
}
}
| 7,855 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
ExtensionFileFilter.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/main/java/org/jfree/chart/ui/ExtensionFileFilter.java | /* ===========================================================
* 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.]
*
* ------------------------
* ExtensionFileFilter.java
* ------------------------
* (C) Copyright 2000-2004, by Object Refinery Limited.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* $Id: ExtensionFileFilter.java,v 1.5 2007/11/02 17:50:36 taqua Exp $
*
* Changes (from 26-Oct-2001)
* --------------------------
* 26-Oct-2001 : Changed package to com.jrefinery.ui.* (DG);
* 26-Jun-2002 : Updated imports (DG);
* 14-Oct-2002 : Fixed errors reported by Checkstyle (DG);
* 14-Jun-2012 : Moved from JCommon to JFreeChart (DG);
*
*/
package org.jfree.chart.ui;
import java.io.File;
import javax.swing.filechooser.FileFilter;
/**
* A filter for JFileChooser that filters files by extension.
*
* @author David Gilbert
*/
public class ExtensionFileFilter extends FileFilter {
/** A description for the file type. */
private String description;
/** The extension (for example, "png" for *.png files). */
private String extension;
/**
* Standard constructor.
*
* @param description a description of the file type;
* @param extension the file extension;
*/
public ExtensionFileFilter(final String description, final String extension) {
this.description = description;
this.extension = extension;
}
/**
* Returns true if the file ends with the specified extension.
*
* @param file the file to test.
*
* @return A boolean that indicates whether or not the file is accepted by the filter.
*/
@Override
public boolean accept(final File file) {
if (file.isDirectory()) {
return true;
}
final String name = file.getName().toLowerCase();
if (name.endsWith(this.extension)) {
return true;
}
return false;
}
/**
* Returns the description of the filter.
*
* @return a description of the filter.
*/
@Override
public String getDescription() {
return this.description;
}
}
| 3,283 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
TextAnchor.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/main/java/org/jfree/chart/ui/TextAnchor.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2013, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* ---------------
* TextAnchor.java
* ---------------
* (C) Copyright 2003-2012, by Object Refinery Limited.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes:
* --------
* 10-Jun-2003 : Version 1 (DG);
* 11-Jan-2005 : Removed deprecated code (DG);
*
*/
package org.jfree.chart.ui;
/**
* Used to indicate the position of an anchor point for a text string. This is
* frequently used to align a string to a fixed point in some coordinate space.
*/
public enum TextAnchor {
/** Top/left. */
TOP_LEFT("TextAnchor.TOP_LEFT"),
/** Top/center. */
TOP_CENTER("TextAnchor.TOP_CENTER"),
/** Top/right. */
TOP_RIGHT("TextAnchor.TOP_RIGHT"),
/** Half-ascent/left. */
HALF_ASCENT_LEFT("TextAnchor.HALF_ASCENT_LEFT"),
/** Half-ascent/center. */
HALF_ASCENT_CENTER("TextAnchor.HALF_ASCENT_CENTER"),
/** Half-ascent/right. */
HALF_ASCENT_RIGHT("TextAnchor.HALF_ASCENT_RIGHT"),
/** Middle/left. */
CENTER_LEFT("TextAnchor.CENTER_LEFT"),
/** Middle/center. */
CENTER("TextAnchor.CENTER"),
/** Middle/right. */
CENTER_RIGHT("TextAnchor.CENTER_RIGHT"),
/** Baseline/left. */
BASELINE_LEFT("TextAnchor.BASELINE_LEFT"),
/** Baseline/center. */
BASELINE_CENTER("TextAnchor.BASELINE_CENTER"),
/** Baseline/right. */
BASELINE_RIGHT("TextAnchor.BASELINE_RIGHT"),
/** Bottom/left. */
BOTTOM_LEFT("TextAnchor.BOTTOM_LEFT"),
/** Bottom/center. */
BOTTOM_CENTER("TextAnchor.BOTTOM_CENTER"),
/** Bottom/right. */
BOTTOM_RIGHT("TextAnchor.BOTTOM_RIGHT");
/** The name. */
private String name;
/**
* Private constructor.
*
* @param name the name.
*/
private TextAnchor(final String name) {
this.name = name;
}
/**
* Returns <code>true</code> if this anchor is at the left side of the
* text bounds, and <code>false</code> otherwise.
*
* @return A boolean.
*/
public boolean isHorizontalLeft() {
return this == TOP_LEFT || this == CENTER_LEFT
|| this == HALF_ASCENT_LEFT || this == BASELINE_LEFT
|| this == BOTTOM_LEFT;
}
/**
* Returns <code>true</code> if this anchor is horizontally at the center
* of the text bounds, and <code>false</code> otherwise.
*
* @return A boolean.
*/
public boolean isHorizontalCenter() {
return this == TOP_CENTER || this == CENTER
|| this == HALF_ASCENT_CENTER || this == BASELINE_CENTER
|| this == BOTTOM_CENTER;
}
/**
* Returns <code>true</code> if this anchor is at the right side of the
* text bounds, and <code>false</code> otherwise.
*
* @return A boolean.
*/
public boolean isHorizontalRight() {
return this == TOP_RIGHT || this == CENTER_RIGHT
|| this == HALF_ASCENT_RIGHT || this == BASELINE_RIGHT
|| this == BOTTOM_RIGHT;
}
/**
* Returns <code>true</code> if this anchor is at the top of the
* text bounds, and <code>false</code> otherwise.
*
* @return A boolean.
*/
public boolean isTop() {
return this == TOP_LEFT || this == TOP_CENTER || this == TOP_RIGHT;
}
/**
* Returns <code>true</code> if this anchor is at the half-ascent level of
* the text bounds, and <code>false</code> otherwise.
*
* @return A boolean.
*/
public boolean isHalfAscent() {
return this == HALF_ASCENT_LEFT || this == HALF_ASCENT_CENTER
|| this == HALF_ASCENT_RIGHT;
}
/**
* Returns <code>true</code> if this anchor is at the half-height level of
* the text bounds, and <code>false</code> otherwise.
*
* @return A boolean.
*/
public boolean isHalfHeight() {
return this == CENTER_LEFT || this == CENTER || this == CENTER_RIGHT;
}
/**
* Returns <code>true</code> if this anchor is at the baseline level of
* the text bounds, and <code>false</code> otherwise.
*
* @return A boolean.
*/
public boolean isBaseline() {
return this == BASELINE_LEFT || this == BASELINE_CENTER
|| this == BASELINE_RIGHT;
}
/**
* Returns <code>true</code> if this anchor is at the bottom of
* the text bounds, and <code>false</code> otherwise.
*
* @return A boolean.
*/
public boolean isBottom() {
return this == BOTTOM_LEFT || this == BOTTOM_CENTER
|| this == BOTTOM_RIGHT;
}
/**
* Returns a string representing the object.
*
* @return The string.
*/
@Override
public String toString() {
return this.name;
}
}
| 6,079 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
RectangleEdge.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/main/java/org/jfree/chart/ui/RectangleEdge.java | /* ===========================================================
* 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.]
*
* -------------
* RectangleEdge
* -------------
* (C) Copyright 2003-2012, by Object Refinery Limited.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes:
* --------
* 14-Jul-2003 (DG);
* 15-Jun-2012 : Moved from JCommon to JFreeChart (DG);
*
*/
package org.jfree.chart.ui;
import java.awt.geom.Rectangle2D;
/**
* Used to indicate the edge of a rectangle.
*/
public enum RectangleEdge {
/** Top. */
TOP("RectangleEdge.TOP"),
/** Bottom. */
BOTTOM("RectangleEdge.BOTTOM"),
/** Left. */
LEFT("RectangleEdge.LEFT"),
/** Right. */
RIGHT("RectangleEdge.RIGHT");
/** The name. */
private String name;
/**
* Private constructor.
*
* @param name the name.
*/
private RectangleEdge(final String name) {
this.name = name;
}
/**
* Returns a string representing the object.
*
* @return The string.
*/
@Override
public String toString() {
return this.name;
}
/**
* Returns <code>true</code> if the edge is <code>TOP</code> or
* <code>BOTTOM</code>, and <code>false</code> otherwise.
*
* @param edge the edge.
*
* @return A boolean.
*/
public static boolean isTopOrBottom(final RectangleEdge edge) {
return (edge == RectangleEdge.TOP || edge == RectangleEdge.BOTTOM);
}
/**
* Returns <code>true</code> if the edge is <code>LEFT</code> or
* <code>RIGHT</code>, and <code>false</code> otherwise.
*
* @param edge the edge.
*
* @return A boolean.
*/
public static boolean isLeftOrRight(final RectangleEdge edge) {
return (edge == RectangleEdge.LEFT || edge == RectangleEdge.RIGHT);
}
/**
* Returns the opposite edge.
*
* @param edge an edge.
*
* @return The opposite edge.
*/
public static RectangleEdge opposite(final RectangleEdge edge) {
RectangleEdge result = null;
if (edge == RectangleEdge.TOP) {
result = RectangleEdge.BOTTOM;
}
else if (edge == RectangleEdge.BOTTOM) {
result = RectangleEdge.TOP;
}
else if (edge == RectangleEdge.LEFT) {
result = RectangleEdge.RIGHT;
}
else if (edge == RectangleEdge.RIGHT) {
result = RectangleEdge.LEFT;
}
return result;
}
/**
* Returns the x or y coordinate of the specified edge.
*
* @param rectangle the rectangle.
* @param edge the edge.
*
* @return The coordinate.
*/
public static double coordinate(final Rectangle2D rectangle,
final RectangleEdge edge) {
double result = 0.0;
if (edge == RectangleEdge.TOP) {
result = rectangle.getMinY();
}
else if (edge == RectangleEdge.BOTTOM) {
result = rectangle.getMaxY();
}
else if (edge == RectangleEdge.LEFT) {
result = rectangle.getMinX();
}
else if (edge == RectangleEdge.RIGHT) {
result = rectangle.getMaxX();
}
return result;
}
}
| 4,434 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
VerticalAlignment.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/main/java/org/jfree/chart/ui/VerticalAlignment.java | /* ===========================================================
* 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.]
*
* ----------------------
* VerticalAlignment.java
* ----------------------
* (C) Copyright 2004-2012, by Object Refinery Limited.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes:
* --------
* 08-Jan-2004 : Version 1 (DG);
* 16-Jun-2012 : Moved from JCommon to JFreeChart (DG);
*
*/
package org.jfree.chart.ui;
/**
* An enumeration of the vertical alignment types (<code>TOP</code>,
* <code>BOTTOM</code> and <code>CENTER</code>).
*/
public enum VerticalAlignment {
/** Top alignment. */
TOP("VerticalAlignment.TOP"),
/** Bottom alignment. */
BOTTOM("VerticalAlignment.BOTTOM"),
/** Center alignment. */
CENTER("VerticalAlignment.CENTER");
/** The name. */
private String name;
/**
* Private constructor.
*
* @param name the name.
*/
private VerticalAlignment(final String name) {
this.name = name;
}
/**
* Returns a string representing the object.
*
* @return the string.
*/
@Override
public String toString() {
return this.name;
}
}
| 2,354 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
GradientPaintTransformType.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/main/java/org/jfree/chart/ui/GradientPaintTransformType.java | /* ===========================================================
* 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.]
*
* -------------------------------
* GradientPaintTransformType.java
* -------------------------------
* (C) Copyright 2003-2012, by Object Refinery Limited.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes:
* --------
* 21-Oct-2003 : Version 1 (DG);
* 12-Jun-2012 : Moved from JCommon to JFreeChart (DG);
*
*/
package org.jfree.chart.ui;
/**
* Represents a type of transform for a <code>GradientPaint</code>.
*
* @author David Gilbert
*/
public enum GradientPaintTransformType {
/** Vertical. */
VERTICAL("GradientPaintTransformType.VERTICAL"),
/** Horizontal. */
HORIZONTAL("GradientPaintTransformType.HORIZONTAL"),
/** Center/vertical. */
CENTER_VERTICAL("GradientPaintTransformType.CENTER_VERTICAL"),
/** Center/horizontal. */
CENTER_HORIZONTAL("GradientPaintTransformType.CENTER_HORIZONTAL");
/** The name. */
private String name;
/**
* Private constructor.
*
* @param name the name.
*/
private GradientPaintTransformType(final String name) {
this.name = name;
}
/**
* Returns a string representing the object.
*
* @return The string.
*/
@Override
public String toString() {
return this.name;
}
}
| 2,531 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
RectangleInsets.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/main/java/org/jfree/chart/ui/RectangleInsets.java | /* ===========================================================
* 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.]
*
* --------------------
* RectangleInsets.java
* --------------------
* (C) Copyright 2004-2012, by Object Refinery Limited.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* $Id: RectangleInsets.java,v 1.15 2007/03/16 14:29:45 mungady Exp $
*
* Changes:
* --------
* 11-Feb-2004 : Version 1 (DG);
* 14-Jun-2004 : Implemented Serializable (DG);
* 02-Feb-2005 : Added new methods and renamed some existing methods (DG);
* 22-Feb-2005 : Added a new constructor for convenience (DG);
* 19-Apr-2005 : Changed order of parameters in constructors to match
* java.awt.Insets (DG);
* 16-Mar-2007 : Added default constructor (DG);
* 16-Jun-2012 : Moved from JCommon to JFreeChart (DG);
*
*/
package org.jfree.chart.ui;
import java.awt.geom.Rectangle2D;
import java.io.Serializable;
import org.jfree.chart.util.UnitType;
/**
* Represents the insets for a rectangle, specified in absolute or relative
* terms. This class is immutable.
*/
public class RectangleInsets implements Serializable {
/** For serialization. */
private static final long serialVersionUID = 1902273207559319996L;
/**
* A useful constant representing zero insets.
*/
public static final RectangleInsets ZERO_INSETS = new RectangleInsets(
UnitType.ABSOLUTE, 0.0, 0.0, 0.0, 0.0);
/** Absolute or relative units. */
private UnitType unitType;
/** The top insets. */
private double top;
/** The left insets. */
private double left;
/** The bottom insets. */
private double bottom;
/** The right insets. */
private double right;
/**
* Creates a new instance with all insets initialised to <code>1.0</code>.
*
* @since 1.0.9
*/
public RectangleInsets() {
this(1.0, 1.0, 1.0, 1.0);
}
/**
* Creates a new instance with the specified insets (as 'absolute' units).
*
* @param top the top insets.
* @param left the left insets.
* @param bottom the bottom insets.
* @param right the right insets.
*/
public RectangleInsets(final double top, final double left,
final double bottom, final double right) {
this(UnitType.ABSOLUTE, top, left, bottom, right);
}
/**
* Creates a new instance.
*
* @param unitType absolute or relative units (<code>null</code> not
* permitted).
* @param top the top insets.
* @param left the left insets.
* @param bottom the bottom insets.
* @param right the right insets.
*/
public RectangleInsets(final UnitType unitType,
final double top, final double left,
final double bottom, final double right) {
if (unitType == null) {
throw new IllegalArgumentException("Null 'unitType' argument.");
}
this.unitType = unitType;
this.top = top;
this.bottom = bottom;
this.left = left;
this.right = right;
}
/**
* Returns the unit type (absolute or relative). This specifies whether
* the insets are measured as Java2D units or percentages.
*
* @return The unit type (never <code>null</code>).
*/
public UnitType getUnitType() {
return this.unitType;
}
/**
* Returns the top insets.
*
* @return The top insets.
*/
public double getTop() {
return this.top;
}
/**
* Returns the bottom insets.
*
* @return The bottom insets.
*/
public double getBottom() {
return this.bottom;
}
/**
* Returns the left insets.
*
* @return The left insets.
*/
public double getLeft() {
return this.left;
}
/**
* Returns the right insets.
*
* @return The right insets.
*/
public double getRight() {
return this.right;
}
/**
* Tests this instance for equality with an arbitrary object.
*
* @param obj the object (<code>null</code> permitted).
*
* @return A boolean.
*/
@Override
public boolean equals(final Object obj) {
if (obj == this) {
return true;
}
if (!(obj instanceof RectangleInsets)) {
return false;
}
final RectangleInsets that = (RectangleInsets) obj;
if (that.unitType != this.unitType) {
return false;
}
if (this.left != that.left) {
return false;
}
if (this.right != that.right) {
return false;
}
if (this.top != that.top) {
return false;
}
if (this.bottom != that.bottom) {
return false;
}
return true;
}
/**
* Returns a hash code for the object.
*
* @return A hash code.
*/
@Override
public int hashCode() {
int result;
long temp;
result = (this.unitType != null ? this.unitType.hashCode() : 0);
temp = this.top != +0.0d ? Double.doubleToLongBits(this.top) : 0L;
result = 29 * result + (int) (temp ^ (temp >>> 32));
temp = this.bottom != +0.0d ? Double.doubleToLongBits(this.bottom) : 0L;
result = 29 * result + (int) (temp ^ (temp >>> 32));
temp = this.left != +0.0d ? Double.doubleToLongBits(this.left) : 0L;
result = 29 * result + (int) (temp ^ (temp >>> 32));
temp = this.right != +0.0d ? Double.doubleToLongBits(this.right) : 0L;
result = 29 * result + (int) (temp ^ (temp >>> 32));
return result;
}
/**
* Returns a textual representation of this instance, useful for debugging
* purposes.
*
* @return A string representing this instance.
*/
@Override
public String toString() {
return "RectangleInsets[t=" + this.top + ",l=" + this.left
+ ",b=" + this.bottom + ",r=" + this.right + "]";
}
/**
* Creates an adjusted rectangle using the supplied rectangle, the insets
* specified by this instance, and the horizontal and vertical
* adjustment types.
*
* @param base the base rectangle (<code>null</code> not permitted).
* @param horizontal the horizontal adjustment type (<code>null</code> not
* permitted).
* @param vertical the vertical adjustment type (<code>null</code> not
* permitted).
*
* @return The inset rectangle.
*/
public Rectangle2D createAdjustedRectangle(final Rectangle2D base,
final LengthAdjustmentType horizontal,
final LengthAdjustmentType vertical) {
if (base == null) {
throw new IllegalArgumentException("Null 'base' argument.");
}
double x = base.getX();
double y = base.getY();
double w = base.getWidth();
double h = base.getHeight();
if (horizontal == LengthAdjustmentType.EXPAND) {
final double leftOutset = calculateLeftOutset(w);
x = x - leftOutset;
w = w + leftOutset + calculateRightOutset(w);
}
else if (horizontal == LengthAdjustmentType.CONTRACT) {
final double leftMargin = calculateLeftInset(w);
x = x + leftMargin;
w = w - leftMargin - calculateRightInset(w);
}
if (vertical == LengthAdjustmentType.EXPAND) {
final double topMargin = calculateTopOutset(h);
y = y - topMargin;
h = h + topMargin + calculateBottomOutset(h);
}
else if (vertical == LengthAdjustmentType.CONTRACT) {
final double topMargin = calculateTopInset(h);
y = y + topMargin;
h = h - topMargin - calculateBottomInset(h);
}
return new Rectangle2D.Double(x, y, w, h);
}
/**
* Creates an 'inset' rectangle.
*
* @param base the base rectangle (<code>null</code> not permitted).
*
* @return The inset rectangle.
*/
public Rectangle2D createInsetRectangle(final Rectangle2D base) {
return createInsetRectangle(base, true, true);
}
/**
* Creates an 'inset' rectangle.
*
* @param base the base rectangle (<code>null</code> not permitted).
* @param horizontal apply horizontal insets?
* @param vertical apply vertical insets?
*
* @return The inset rectangle.
*/
public Rectangle2D createInsetRectangle(final Rectangle2D base,
final boolean horizontal,
final boolean vertical) {
if (base == null) {
throw new IllegalArgumentException("Null 'base' argument.");
}
double topMargin = 0.0;
double bottomMargin = 0.0;
if (vertical) {
topMargin = calculateTopInset(base.getHeight());
bottomMargin = calculateBottomInset(base.getHeight());
}
double leftMargin = 0.0;
double rightMargin = 0.0;
if (horizontal) {
leftMargin = calculateLeftInset(base.getWidth());
rightMargin = calculateRightInset(base.getWidth());
}
return new Rectangle2D.Double(
base.getX() + leftMargin,
base.getY() + topMargin,
base.getWidth() - leftMargin - rightMargin,
base.getHeight() - topMargin - bottomMargin
);
}
/**
* Creates an outset rectangle.
*
* @param base the base rectangle (<code>null</code> not permitted).
*
* @return An outset rectangle.
*/
public Rectangle2D createOutsetRectangle(final Rectangle2D base) {
return createOutsetRectangle(base, true, true);
}
/**
* Creates an outset rectangle.
*
* @param base the base rectangle (<code>null</code> not permitted).
* @param horizontal apply horizontal insets?
* @param vertical apply vertical insets?
*
* @return An outset rectangle.
*/
public Rectangle2D createOutsetRectangle(final Rectangle2D base,
final boolean horizontal,
final boolean vertical) {
if (base == null) {
throw new IllegalArgumentException("Null 'base' argument.");
}
double topMargin = 0.0;
double bottomMargin = 0.0;
if (vertical) {
topMargin = calculateTopOutset(base.getHeight());
bottomMargin = calculateBottomOutset(base.getHeight());
}
double leftMargin = 0.0;
double rightMargin = 0.0;
if (horizontal) {
leftMargin = calculateLeftOutset(base.getWidth());
rightMargin = calculateRightOutset(base.getWidth());
}
return new Rectangle2D.Double(
base.getX() - leftMargin,
base.getY() - topMargin,
base.getWidth() + leftMargin + rightMargin,
base.getHeight() + topMargin + bottomMargin
);
}
/**
* Returns the top margin.
*
* @param height the height of the base rectangle.
*
* @return The top margin (in Java2D units).
*/
public double calculateTopInset(final double height) {
double result = this.top;
if (this.unitType == UnitType.RELATIVE) {
result = (this.top * height);
}
return result;
}
/**
* Returns the top margin.
*
* @param height the height of the base rectangle.
*
* @return The top margin (in Java2D units).
*/
public double calculateTopOutset(final double height) {
double result = this.top;
if (this.unitType == UnitType.RELATIVE) {
result = (height / (1 - this.top - this.bottom)) * this.top;
}
return result;
}
/**
* Returns the bottom margin.
*
* @param height the height of the base rectangle.
*
* @return The bottom margin (in Java2D units).
*/
public double calculateBottomInset(final double height) {
double result = this.bottom;
if (this.unitType == UnitType.RELATIVE) {
result = (this.bottom * height);
}
return result;
}
/**
* Returns the bottom margin.
*
* @param height the height of the base rectangle.
*
* @return The bottom margin (in Java2D units).
*/
public double calculateBottomOutset(final double height) {
double result = this.bottom;
if (this.unitType == UnitType.RELATIVE) {
result = (height / (1 - this.top - this.bottom)) * this.bottom;
}
return result;
}
/**
* Returns the left margin.
*
* @param width the width of the base rectangle.
*
* @return The left margin (in Java2D units).
*/
public double calculateLeftInset(final double width) {
double result = this.left;
if (this.unitType == UnitType.RELATIVE) {
result = (this.left * width);
}
return result;
}
/**
* Returns the left margin.
*
* @param width the width of the base rectangle.
*
* @return The left margin (in Java2D units).
*/
public double calculateLeftOutset(final double width) {
double result = this.left;
if (this.unitType == UnitType.RELATIVE) {
result = (width / (1 - this.left - this.right)) * this.left;
}
return result;
}
/**
* Returns the right margin.
*
* @param width the width of the base rectangle.
*
* @return The right margin (in Java2D units).
*/
public double calculateRightInset(final double width) {
double result = this.right;
if (this.unitType == UnitType.RELATIVE) {
result = (this.right * width);
}
return result;
}
/**
* Returns the right margin.
*
* @param width the width of the base rectangle.
*
* @return The right margin (in Java2D units).
*/
public double calculateRightOutset(final double width) {
double result = this.right;
if (this.unitType == UnitType.RELATIVE) {
result = (width / (1 - this.left - this.right)) * this.right;
}
return result;
}
/**
* Trims the given width to allow for the insets.
*
* @param width the width.
*
* @return The trimmed width.
*/
public double trimWidth(final double width) {
return width - calculateLeftInset(width) - calculateRightInset(width);
}
/**
* Extends the given width to allow for the insets.
*
* @param width the width.
*
* @return The extended width.
*/
public double extendWidth(final double width) {
return width + calculateLeftOutset(width) + calculateRightOutset(width);
}
/**
* Trims the given height to allow for the insets.
*
* @param height the height.
*
* @return The trimmed height.
*/
public double trimHeight(final double height) {
return height
- calculateTopInset(height) - calculateBottomInset(height);
}
/**
* Extends the given height to allow for the insets.
*
* @param height the height.
*
* @return The extended height.
*/
public double extendHeight(final double height) {
return height
+ calculateTopOutset(height) + calculateBottomOutset(height);
}
/**
* Shrinks the given rectangle by the amount of these insets.
*
* @param area the area (<code>null</code> not permitted).
*/
public void trim(final Rectangle2D area) {
final double w = area.getWidth();
final double h = area.getHeight();
final double l = calculateLeftInset(w);
final double r = calculateRightInset(w);
final double t = calculateTopInset(h);
final double b = calculateBottomInset(h);
area.setRect(area.getX() + l, area.getY() + t, w - l - r, h - t - b);
}
}
| 17,500 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
Align.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/main/java/org/jfree/chart/ui/Align.java | /* ===========================================================
* 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.]
*
* ----------
* Align.java
* ----------
* (C) Copyright 2000-2012, by Object Refinery Limited and Contributors.
*
* Original Author: Christian W. Zuckschwerdt;
* Contributor(s): David Gilbert (for Object Refinery Limited);
*
* Changes (from 30-May-2002)
* --------------------------
* 30-May-2002 : Added title (DG);
* 13-Oct-2002 : Fixed errors reported by Checkstyle (DG);
* 14-Jun-2012 : Moved from JCommon into JFreeChart (DG);
*
*/
package org.jfree.chart.ui;
import java.awt.geom.Rectangle2D;
/**
* A utility class for aligning rectangles.
*/
public final class Align {
/** Center alignment. */
public static final int CENTER = 0x00;
/** Top alignment. */
public static final int TOP = 0x01;
/** Bottom alignment. */
public static final int BOTTOM = 0x02;
/** Left alignment. */
public static final int LEFT = 0x04;
/** Right alignment. */
public static final int RIGHT = 0x08;
/** Top/Left alignment. */
public static final int TOP_LEFT = TOP | LEFT;
/** Top/Right alignment. */
public static final int TOP_RIGHT = TOP | RIGHT;
/** Bottom/Left alignment. */
public static final int BOTTOM_LEFT = BOTTOM | LEFT;
/** Bottom/Right alignment. */
public static final int BOTTOM_RIGHT = BOTTOM | RIGHT;
/** Horizontal fit. */
public static final int FIT_HORIZONTAL = LEFT | RIGHT;
/** Vertical fit. */
public static final int FIT_VERTICAL = TOP | BOTTOM;
/** Complete fit. */
public static final int FIT = FIT_HORIZONTAL | FIT_VERTICAL;
/** North alignment (same as TOP). */
public static final int NORTH = TOP;
/** South alignment (same as BOTTOM). */
public static final int SOUTH = BOTTOM;
/** West alignment (same as LEFT). */
public static final int WEST = LEFT;
/** East alignment (same as RIGHT). */
public static final int EAST = RIGHT;
/** North/West alignment (same as TOP_LEFT). */
public static final int NORTH_WEST = NORTH | WEST;
/** North/East alignment (same as TOP_RIGHT). */
public static final int NORTH_EAST = NORTH | EAST;
/** South/West alignment (same as BOTTOM_LEFT). */
public static final int SOUTH_WEST = SOUTH | WEST;
/** South/East alignment (same as BOTTOM_RIGHT). */
public static final int SOUTH_EAST = SOUTH | EAST;
/**
* Private constructor.
*/
private Align() {
super();
}
/**
* Aligns one rectangle (<code>rect</code>) relative to another rectangle (<code>frame</code>).
*
* @param rect the rectangle to be aligned (<code>null</code> not permitted).
* @param frame the reference frame (<code>null</code> not permitted).
* @param align the alignment code.
*/
public static void align(final Rectangle2D rect, final Rectangle2D frame, final int align) {
double x = frame.getCenterX() - rect.getWidth() / 2.0;
double y = frame.getCenterY() - rect.getHeight() / 2.0;
double w = rect.getWidth();
double h = rect.getHeight();
if ((align & FIT_VERTICAL) == FIT_VERTICAL) {
h = frame.getHeight();
}
if ((align & FIT_HORIZONTAL) == FIT_HORIZONTAL) {
w = frame.getWidth();
}
if ((align & TOP) == TOP) {
y = frame.getMinY();
}
if ((align & BOTTOM) == BOTTOM) {
y = frame.getMaxY() - h;
}
if ((align & LEFT) == LEFT) {
x = frame.getX();
}
if ((align & RIGHT) == RIGHT) {
x = frame.getMaxX() - w;
}
rect.setRect(x, y, w, h);
}
}
| 4,880 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
StandardGradientPaintTransformer.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/main/java/org/jfree/chart/ui/StandardGradientPaintTransformer.java | /* ===========================================================
* 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.]
*
* -------------------------------------
* StandardGradientPaintTransformer.java
* -------------------------------------
* (C) Copyright 2003-2012, by Object Refinery Limited.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* $Id: StandardGradientPaintTransformer.java,v 1.11 2007/04/03 13:55:13 mungady Exp $
*
* Changes
* -------
* 28-Oct-2003 : Version 1 (DG);
* 19-Mar-2004 : Added equals() method (DG);
* 17-Jun-2012 : Moved from JCommon to JFreeChart (DG);
*
*/
package org.jfree.chart.ui;
import java.awt.GradientPaint;
import java.awt.Shape;
import java.awt.geom.Rectangle2D;
import java.io.Serializable;
import org.jfree.chart.util.PublicCloneable;
/**
* Transforms a <code>GradientPaint</code> to range over the width of a target
* shape. Instances of this class are immutable.
*/
public class StandardGradientPaintTransformer
implements GradientPaintTransformer, Cloneable, PublicCloneable,
Serializable {
/** For serialization. */
private static final long serialVersionUID = -8155025776964678320L;
/** The transform type. */
private GradientPaintTransformType type;
/**
* Creates a new transformer with the type
* {@link GradientPaintTransformType#VERTICAL}.
*/
public StandardGradientPaintTransformer() {
this(GradientPaintTransformType.VERTICAL);
}
/**
* Creates a new transformer with the specified type.
*
* @param type the transform type (<code>null</code> not permitted).
*/
public StandardGradientPaintTransformer(
final GradientPaintTransformType type) {
if (type == null) {
throw new IllegalArgumentException("Null 'type' argument.");
}
this.type = type;
}
/**
* Returns the type of transform.
*
* @return The type of transform (never <code>null</code>).
*
* @since 1.0.10
*/
public GradientPaintTransformType getType() {
return this.type;
}
/**
* Transforms a <code>GradientPaint</code> instance to fit the specified
* <code>target</code> shape.
*
* @param paint the original paint (<code>null</code> not permitted).
* @param target the target shape (<code>null</code> not permitted).
*
* @return The transformed paint.
*/
@Override
public GradientPaint transform(final GradientPaint paint,
final Shape target) {
GradientPaint result = paint;
final Rectangle2D bounds = target.getBounds2D();
if (this.type.equals(GradientPaintTransformType.VERTICAL)) {
result = new GradientPaint((float) bounds.getCenterX(),
(float) bounds.getMinY(), paint.getColor1(),
(float) bounds.getCenterX(), (float) bounds.getMaxY(),
paint.getColor2());
}
else if (this.type.equals(GradientPaintTransformType.HORIZONTAL)) {
result = new GradientPaint((float) bounds.getMinX(),
(float) bounds.getCenterY(), paint.getColor1(),
(float) bounds.getMaxX(), (float) bounds.getCenterY(),
paint.getColor2());
}
else if (this.type.equals(
GradientPaintTransformType.CENTER_HORIZONTAL)) {
result = new GradientPaint((float) bounds.getCenterX(),
(float) bounds.getCenterY(), paint.getColor2(),
(float) bounds.getMaxX(), (float) bounds.getCenterY(),
paint.getColor1(), true);
}
else if (this.type.equals(GradientPaintTransformType.CENTER_VERTICAL)) {
result = new GradientPaint((float) bounds.getCenterX(),
(float) bounds.getMinY(), paint.getColor1(),
(float) bounds.getCenterX(), (float) bounds.getCenterY(),
paint.getColor2(), true);
}
return result;
}
/**
* Tests this instance for equality with an arbitrary object.
*
* @param obj the object (<code>null</code> permitted).
*
* @return A boolean.
*/
@Override
public boolean equals(final Object obj) {
if (obj == this) {
return true;
}
if (!(obj instanceof StandardGradientPaintTransformer)) {
return false;
}
StandardGradientPaintTransformer that
= (StandardGradientPaintTransformer) obj;
if (this.type != that.type) {
return false;
}
return true;
}
/**
* Returns a clone of the transformer. Note that instances of this class
* are immutable, so cloning an instance isn't really necessary.
*
* @return A clone.
*
* @throws CloneNotSupportedException not thrown by this class, but
* subclasses (if any) might.
*/
@Override
public Object clone() throws CloneNotSupportedException {
return super.clone();
}
/**
* Returns a hash code for this object.
*
* @return A hash code.
*/
@Override
public int hashCode() {
return (this.type != null ? this.type.hashCode() : 0);
}
}
| 6,477 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.