public class Chart3D extends java.lang.Object implements Drawable3D, ChartElement, Plot3DChangeListener, ChartStyleChangeListener, java.io.Serializable
Chart3DFactory class provides
some factory methods to construct common types of charts.
Graphics2D target (such as the screen, image, SVG file or
PDF file).
TableElement instance. The TitleUtils
class contains methods to create a common title/subtitle composite title.
This is illustrated in some of the demo applications. The chart title
and legend (and also the axis labels) are not part of the 3D world model,
they are overlaid on the output after the 3D components have been
rendered.
Chart3DFactory,
Chart3DPanel,
Serialized Form| Modifier and Type | Field and Description |
|---|---|
static double |
DEFAULT_PROJ_DIST
The default projection distance.
|
static java.lang.String |
INTERACTIVE_ELEMENT_TYPE
The key for a property that stores the interactive element type.
|
static java.lang.String |
SERIES_KEY
The key for a property that stores the series key.
|
| Constructor and Description |
|---|
Chart3D(java.lang.String title,
java.lang.String subtitle,
Plot3D plot)
Creates a 3D chart for the specified plot using the default chart
style.
|
Chart3D(java.lang.String title,
java.lang.String subtitle,
Plot3D plot,
ChartStyle style)
Creates a 3D chart for the specified plot using the supplied style.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addChangeListener(Chart3DChangeListener listener)
Registers a listener to receive notification of changes to the chart.
|
RenderingInfo |
draw(java.awt.Graphics2D g2,
java.awt.geom.Rectangle2D bounds)
Draws the chart to the specified output target.
|
boolean |
equals(java.lang.Object obj)
Tests this chart for equality with an arbitrary object.
|
protected void |
fireChangeEvent()
Sends a
Chart3DChangeEvent to all registered listeners. |
boolean |
getAntiAlias()
Returns a flag that indicates whether or not anti-aliasing is used when
the chart is drawn.
|
RectanglePainter |
getBackground()
Returns the background painter (an object that is responsible for filling
the background area before charts are rendered).
|
java.awt.Color |
getChartBoxColor()
Returns the chart box color (the chart box is the visible, open-sided
box inside which data is plotted for all charts except pie charts).
|
Dimension3D |
getDimensions()
Returns the dimensions of the 3D object.
|
boolean |
getElementHinting()
Returns the flag that controls whether or not element hints will be
added to the
Graphics2D output when the chart is rendered. |
java.lang.String |
getID()
Returns the chart id.
|
Anchor2D |
getLegendAnchor()
Returns the legend anchor.
|
LegendBuilder |
getLegendBuilder()
Returns the legend builder.
|
Orientation |
getLegendOrientation()
Returns the orientation for the legend.
|
Plot3D |
getPlot()
Returns the plot, which manages the dataset, the axes (if any), the
renderer (if any) and other attributes related to plotting data.
|
double |
getProjDistance()
Returns the projection distance.
|
java.awt.RenderingHints |
getRenderingHints()
Returns the collection of rendering hints for the chart.
|
ChartStyle |
getStyle()
Returns the chart style.
|
TableElement |
getTitle()
Returns the chart title.
|
Anchor2D |
getTitleAnchor()
Returns the title anchor.
|
Offset2D |
getTranslate2D()
Sets the offset in 2D-space for the rendering of the chart.
|
ViewPoint3D |
getViewPoint()
Returns the view point.
|
boolean |
isNotify()
Returns a flag that controls whether or not change events are sent to
registered listeners.
|
void |
notifyListeners(Chart3DChangeEvent event)
Notifies all registered listeners that the chart has been modified.
|
void |
plotChanged(Plot3DChangeEvent event)
Receives notification of a plot change event, refreshes the 3D model
(world) and passes the event on, wrapped in a
Chart3DChangeEvent,
to all registered listeners. |
void |
receive(ChartElementVisitor visitor)
Receives a visitor.
|
void |
removeChangeListener(Chart3DChangeListener listener)
Deregisters a listener so that it no longer receives notification of
changes to the chart.
|
static java.lang.String |
renderedElementToString(RenderedElement element)
Returns a string representing the
element, primarily for
debugging purposes. |
void |
setAntiAlias(boolean flag)
Sets a flag that indicates whether or not anti-aliasing is used when the
chart is drawn.
|
void |
setBackground(RectanglePainter background)
Sets the background painter and sends a
Chart3DChangeEvent to
all registered listeners. |
void |
setChartBoxColor(java.awt.Color color)
Sets the chart box color and sends a
Chart3DChangeEvent to all
registered listeners. |
void |
setElementHinting(boolean hinting)
Sets the flag that controls whether or not element hints will be
added to the
Graphics2D output when the chart is rendered
and sends a change event to all registered listeners. |
void |
setID(java.lang.String id)
Sets the chart id.
|
void |
setLegendAnchor(Anchor2D anchor)
Sets the legend anchor and sends a
Chart3DChangeEvent to all
registered listeners. |
void |
setLegendBuilder(LegendBuilder legendBuilder)
Sets the legend builder and sends a change event to all registered
listeners.
|
void |
setLegendOrientation(Orientation orientation)
Sets the legend orientation and sends a
Chart3DChangeEvent
to all registered listeners. |
void |
setLegendPosition(Anchor2D anchor,
Orientation orientation)
Sets the legend position (both the anchor point and the orientation) and
sends a
Chart3DChangeEvent to all registered listeners. |
void |
setNotify(boolean notify)
Sets a flag that controls whether or not listeners receive
Chart3DChangeEvent notifications. |
void |
setProjDistance(double dist)
Sets the projection distance and sends a change event to all registered
listeners.
|
void |
setRenderingHints(java.awt.RenderingHints hints)
Sets the rendering hints for the chart.
|
void |
setStyle(ChartStyle style)
Sets (and applies) the specified chart style.
|
void |
setTitle(java.lang.String title)
Sets the chart title and sends a
Chart3DChangeEvent to all
registered listeners. |
void |
setTitle(java.lang.String title,
java.awt.Font font,
java.awt.Color color)
Sets the chart title and sends a
Chart3DChangeEvent to all
registered listeners. |
void |
setTitle(TableElement title)
Sets the chart title and sends a
Chart3DChangeEvent to all
registered listeners. |
void |
setTitleAnchor(Anchor2D anchor)
Sets the title anchor and sends a
Chart3DChangeEvent to all
registered listeners. |
void |
setTranslate2D(Offset2D offset)
Sets the offset in 2D-space for the rendering of the chart and sends a
change event to all registered listeners.
|
void |
setViewPoint(ViewPoint3D viewPoint)
Sets the view point.
|
void |
styleChanged(ChartStyleChangeEvent event)
Called to inform that a chart change event has occurred.
|
public static final double DEFAULT_PROJ_DIST
public static final java.lang.String INTERACTIVE_ELEMENT_TYPE
public static final java.lang.String SERIES_KEY
TableElement representing a legend
item, and also on a corresponding RenderedElement after
chart rendering (in the RenderingInfo).public Chart3D(java.lang.String title, java.lang.String subtitle, Plot3D plot)
title - the chart title (null permitted).subtitle - the chart subtitle (null permitted).plot - the plot (null not permitted).Chart3DFactorypublic Chart3D(java.lang.String title, java.lang.String subtitle, Plot3D plot, ChartStyle style)
title - the chart title (null permitted).subtitle - the chart subtitle (null permitted).plot - the plot (null not permitted).style - the chart style (null not permitted).public java.lang.String getID()
null).public void setID(java.lang.String id)
id - the id (null permitted).public RectanglePainter getBackground()
StandardRectanglePainter that paints the
background white.null).setBackground(com.orsoncharts.table.RectanglePainter)public void setBackground(RectanglePainter background)
Chart3DChangeEvent to
all registered listeners. A background painter is used to fill in the
background of the chart before the 3D rendering takes place. To fill
the background with a color or image, you can use
StandardRectanglePainter. To fill the background with a
gradient paint, use GradientRectanglePainter.background - the background painter (null permitted).getBackground()public TableElement getTitle()
TableElement is used for the title,
since it allows a lot of flexibility in the types of title that can
be displayed.null).public void setTitle(java.lang.String title)
Chart3DChangeEvent to all
registered listeners. This is a convenience method that constructs
the required TableElement under-the-hood.title - the title (null permitted).public void setTitle(java.lang.String title, java.awt.Font font, java.awt.Color color)
Chart3DChangeEvent to all
registered listeners. This is a convenience method that constructs
the required TableElement under-the-hood.title - the title (null not permitted).font - the font (null not permitted).color - the foreground color (null not permitted).public void setTitle(TableElement title)
Chart3DChangeEvent to all
registered listeners. You can set the title to null, in
which case there will be no chart title.title - the title (null permitted).public Anchor2D getTitleAnchor()
null).setTitleAnchor(com.orsoncharts.util.Anchor2D)public void setTitleAnchor(Anchor2D anchor)
Chart3DChangeEvent to all
registered listeners. There is a TitleAnchor class providing
some useful default anchors.anchor - the anchor (null not permitted).getTitleAnchor()public Plot3D getPlot()
null).public java.awt.Color getChartBoxColor()
Color.WHITE.null).setChartBoxColor(java.awt.Color)public void setChartBoxColor(java.awt.Color color)
Chart3DChangeEvent to all
registered listeners. Bear in mind that PiePlot3D does not
display a chart box, so this attribute will be ignored for pie charts.color - the color (null not permitted).getChartBoxColor()public Dimension3D getDimensions()
getDimensions in interface Drawable3Dnull).public ViewPoint3D getViewPoint()
getViewPoint in interface Drawable3Dnull).public void setViewPoint(ViewPoint3D viewPoint)
setViewPoint in interface Drawable3DviewPoint - the view point (null not permitted).public double getProjDistance()
DEFAULT_PROJ_DIST, higher numbers flatten out the perspective
and reduce distortion in the projected image.getProjDistance in interface Drawable3Dpublic void setProjDistance(double dist)
setProjDistance in interface Drawable3Ddist - the distance.public Offset2D getTranslate2D()
(0, 0) but the user can modify it via
ALT-mouse-drag in the chart panel, providing an easy way to get improved
chart alignment in the panels (especially prior to export to PNG, SVG or
PDF).getTranslate2D in interface Drawable3Dnull).public void setTranslate2D(Offset2D offset)
setTranslate2D in interface Drawable3Doffset - the new offset (null not permitted).public LegendBuilder getLegendBuilder()
StandardLegendBuilder. If the legend builder is null,
no legend will be displayed for the chart.null).setLegendBuilder(com.orsoncharts.legend.LegendBuilder),
setLegendAnchor(com.orsoncharts.util.Anchor2D)public void setLegendBuilder(LegendBuilder legendBuilder)
null, no legend
will be displayed on the chart.legendBuilder - the legend builder (null permitted).setLegendAnchor(com.orsoncharts.util.Anchor2D)public Anchor2D getLegendAnchor()
null).setLegendAnchor(com.orsoncharts.util.Anchor2D)public void setLegendAnchor(Anchor2D anchor)
Chart3DChangeEvent to all
registered listeners. There is a LegendAnchor class providing
some useful default anchors.anchor - the anchor (null not permitted).getLegendAnchor()public Orientation getLegendOrientation()
null).public void setLegendOrientation(Orientation orientation)
Chart3DChangeEvent
to all registered listeners.orientation - the orientation (null not permitted).public void setLegendPosition(Anchor2D anchor, Orientation orientation)
Chart3DChangeEvent to all registered listeners.
This is a convenience method that calls both the
setLegendAnchor(com.orsoncharts.util.Anchor2D) and
setLegendOrientation(com.orsoncharts.util.Orientation)
methods.anchor - the anchor (null not permitted).orientation - the orientation (null not permitted).public java.awt.RenderingHints getRenderingHints()
null).setRenderingHints(RenderingHints)public void setRenderingHints(java.awt.RenderingHints hints)
Graphics2D.addRenderingHints() method) near the start of
the chart rendering. Note that calling this method will replace all
existing hints assigned to the chart. If you simply wish to add an
additional hint, you can use getRenderingHints().put(key, value).hints - the rendering hints (null not permitted).getRenderingHints()public boolean getAntiAlias()
setAntiAlias(boolean)public void setAntiAlias(boolean flag)
Anti-aliasing usually improves the appearance of charts, but is slower.
flag - the new value of the flag.getAntiAlias()public boolean getElementHinting()
Graphics2D output when the chart is rendered.
The default value is false.public void setElementHinting(boolean hinting)
Graphics2D output when the chart is rendered
and sends a change event to all registered listeners.hinting - the new flag value.public ChartStyle getStyle()
null).public void setStyle(ChartStyle style)
style - the chart style (null not permitted).public RenderingInfo draw(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D bounds)
draw in interface Drawable3Dg2 - the output target (null not permitted).bounds - the bounds (null not permitted).public void receive(ChartElementVisitor visitor)
receive in interface ChartElementvisitor - the visitor.public boolean equals(java.lang.Object obj)
equals in class java.lang.Objectobj - the object (null not permitted).public void plotChanged(Plot3DChangeEvent event)
Chart3DChangeEvent,
to all registered listeners.plotChanged in interface Plot3DChangeListenerevent - the plot change event.public void styleChanged(ChartStyleChangeEvent event)
ChartStyleChangeListenerstyleChanged in interface ChartStyleChangeListenerevent - the event.public void addChangeListener(Chart3DChangeListener listener)
listener - the listener (null not permitted).public void removeChangeListener(Chart3DChangeListener listener)
listener - the listener (null not permitted).public void notifyListeners(Chart3DChangeEvent event)
event - information about the change event.public boolean isNotify()
setNotify(boolean)public void setNotify(boolean notify)
Chart3DChangeEvent notifications.notify - a boolean.isNotify()protected void fireChangeEvent()
Chart3DChangeEvent to all registered listeners.public static java.lang.String renderedElementToString(RenderedElement element)
element, primarily for
debugging purposes.element - the element (null not permitted).null).