本文整理汇总了Java中info.monitorenter.gui.chart.Chart2D类的典型用法代码示例。如果您正苦于以下问题:Java Chart2D类的具体用法?Java Chart2D怎么用?Java Chart2D使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Chart2D类属于info.monitorenter.gui.chart包,在下文中一共展示了Chart2D类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: MultiTracing
import info.monitorenter.gui.chart.Chart2D; //导入依赖的package包/类
/** Defcon. */
public MultiTracing() {
super("MultiTracing");
this.m_chart = new Chart2D();
this.m_chart.getAxisX().setPaintGrid(true);
this.m_chart.getAxisY().setPaintGrid(true);
this.m_chart.setBackground(Color.lightGray);
this.m_chart.setGridColor(new Color(0xDD, 0xDD, 0xDD));
// add WindowListener
this.addWindowListener(new WindowAdapter() {
/**
* @see java.awt.event.WindowAdapter#windowClosing(java.awt.event.WindowEvent)
*/
@Override
public void windowClosing(final WindowEvent e) {
System.exit(0);
}
});
Container contentPane = this.getContentPane();
contentPane.setLayout(new BorderLayout());
contentPane.add(new ChartPanel(this.m_chart), BorderLayout.CENTER);
}
示例2: testLabelSpacing
import info.monitorenter.gui.chart.Chart2D; //导入依赖的package包/类
/**
* Creates a a chart with three traces and different labels and displays it.
* <p>
*
* @throws InterruptedException
*/
public void testLabelSpacing() throws InterruptedException {
JFrame frame = new JFrame(this.getName());
Chart2D chart = new Chart2D();
ITrace2D trace1 = new Trace2DLtd();
trace1.setName("lottolotto");
trace1.setColor(Color.RED);
chart.addTrace(trace1);
ITrace2D trace2 = new Trace2DLtd();
trace2.setName("bbb");
trace2.setColor(Color.BLUE);
chart.addTrace(trace2);
ITrace2D trace3 = new Trace2DLtd();
trace3.setColor(Color.BLACK);
trace3.setName("ffollejolle");
chart.addTrace(trace3);
frame.getContentPane().add(chart);
frame.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
frame.setSize(new Dimension(400, 300));
frame.setVisible(true);
while (frame.isVisible()) {
Thread.sleep(1000);
}
}
示例3: InitChart
import info.monitorenter.gui.chart.Chart2D; //导入依赖的package包/类
/**
* Initialize a chart. This should happen before you want to use
* the chart, either for storing data or displaying data. It's best
* to delay the inits until you need them, because making a lot of charts
* seems to slow down chart interactions.
*
* @param name Name of the trace you want to init
* @return the created chart object
*/
public Chart2D InitChart(String name)
{
Chart2D chart = new Chart2D();
ITrace2D trace = new Trace2DLtd(chartData.sparklineChartSize, name);
chart.addTrace(trace);
// add marker lines to the trace
TracePainterDisc markerPainter = new TracePainterDisc();
markerPainter.setDiscSize(2);
trace.addTracePainter(markerPainter);
return chart;
}
示例4: propertyChangeSynced
import info.monitorenter.gui.chart.Chart2D; //导入依赖的package包/类
/**
* @see info.monitorenter.gui.chart.axis.AAxis.APropertyChangeReactorSynced#propertyChangeSynced(java.beans.PropertyChangeEvent,
* info.monitorenter.gui.chart.axis.AAxis)
*/
@Override
protected boolean propertyChangeSynced(final PropertyChangeEvent changeEvent,
final AAxis<?> receiver) {
boolean result = false;
// now points added or removed -> rescale!
if (Chart2D.DEBUG_SCALING) {
System.out.println("pc-tp");
}
final ITracePoint2D oldPt = (ITracePoint2D) changeEvent.getOldValue();
final ITracePoint2D newPt = (ITracePoint2D) changeEvent.getNewValue();
// added or removed?
// we only care about added points (rescaling is our task)
if (oldPt == null) {
receiver.scalePoint(newPt);
result = true;
}
return result;
}
示例5: scalePoint
import info.monitorenter.gui.chart.Chart2D; //导入依赖的package包/类
/**
* Internally rescales the given <code>{@link ITracePoint2D}</code> in the
* dimension this axis works in.
* <p>
*
* @param point
* the point to scale (between 0.0 and 1.0) according to the internal
* bounds.
*/
protected final void scalePoint(final ITracePoint2D point) {
final int axis = this.getAccessor().getDimension();
if (axis == Chart2D.X) {
point.setScaledX(this.getScaledValue(point.getX()));
} else if (axis == Chart2D.Y) {
point.setScaledY(this.getScaledValue(point.getY()));
}
if (Chart2D.DEBUG_SCALING) {
// This is ok for fixed viewports that zoom!
if ((point.getScaledX() > 1.0) || (point.getScaledX() < 0.0) || (point.getScaledY() > 1.0)
|| (point.getScaledY() < 0.0)) {
System.out.println("Scaled Point " + point + " to [" + point.getScaledX() + ","
+ point.getScaledY() + "]");
}
}
}
示例6: unlisten2Trace
import info.monitorenter.gui.chart.Chart2D; //导入依赖的package包/类
/**
* Removes this axis as a listener for all property change events of the given
* trace that are needed here.
* <p>
* TODO: stick to <code>{@link AAxis#listen2Trace(ITrace2D)}</code>.
* <p>
*
* @param trace
* the trace to not listen to any more.
*/
private void unlisten2Trace(final ITrace2D trace) {
if (this.getAccessor().getDimension() == Chart2D.X) {
trace.removePropertyChangeListener(ITrace2D.PROPERTY_MAX_X, this);
trace.removePropertyChangeListener(ITrace2D.PROPERTY_MIN_X, this);
} else {
trace.removePropertyChangeListener(ITrace2D.PROPERTY_MAX_Y, this);
trace.removePropertyChangeListener(ITrace2D.PROPERTY_MIN_Y, this);
}
trace.removePropertyChangeListener(ITrace2D.PROPERTY_COLOR, this);
trace.removePropertyChangeListener(ITrace2D.PROPERTY_STROKE, this);
trace.removePropertyChangeListener(ITrace2D.PROPERTY_VISIBLE, this);
trace.removePropertyChangeListener(ITrace2D.PROPERTY_ZINDEX, this);
trace.removePropertyChangeListener(ITrace2D.PROPERTY_PAINTERS, this);
trace.removePropertyChangeListener(ITrace2D.PROPERTY_ERRORBARPOLICY, this);
trace.removePropertyChangeListener(ITrace2D.PROPERTY_ERRORBARPOLICY_CONFIGURATION, this);
trace.removePropertyChangeListener(ITrace2D.PROPERTY_ZINDEX, this);
trace.removePropertyChangeListener(ITrace2D.PROPERTY_NAME, this);
trace.removePropertyChangeListener(ITrace2D.PROPERTY_TRACEPOINT, this);
trace.removePropertyChangeListener(ITrace2D.PROPERTY_POINT_CHANGED, this);
}
示例7: createAccessor
import info.monitorenter.gui.chart.Chart2D; //导入依赖的package包/类
/**
* @see info.monitorenter.gui.chart.axis.AAxis#createAccessor(info.monitorenter.gui.chart.Chart2D,
* int, int)
*/
@Override
protected AChart2DDataAccessor createAccessor(final Chart2D chart, final int dimension,
final int position) {
AChart2DDataAccessor result;
if (dimension == Chart2D.X) {
// Don't allow a combination of dimension and position that is not usable:
if ((position & (Chart2D.CHART_POSITION_BOTTOM | Chart2D.CHART_POSITION_TOP)) == 0) {
throw new IllegalArgumentException("X axis only valid with top or bottom position.");
}
this.setAxisPosition(position);
result = new XDataInverseAccessor(chart);
} else if (dimension == Chart2D.Y) {
// Don't allow a combination of dimension and position that is not usable:
if ((position & (Chart2D.CHART_POSITION_LEFT | Chart2D.CHART_POSITION_RIGHT)) == 0) {
throw new IllegalArgumentException("Y axis only valid with left or right position.");
}
this.setAxisPosition(position);
result = new YDataInverseAccessor(chart);
} else {
throw new IllegalArgumentException("Dimension has to be Chart2D.X or Chart2D.Y!");
}
return result;
}
示例8: expandMaxYErrorBarBounds
import info.monitorenter.gui.chart.Chart2D; //导入依赖的package包/类
/**
* Internally takes into account that in case of error bars to render the
* maximum y value will be different.
* <p>
* Returns true if a change to <code>{@link #getMaxY()}</code> was done.
* <p>
*
* @return true if a change to <code>{@link #getMaxY()}</code> was done.
*/
private boolean expandMaxYErrorBarBounds() {
final Chart2D chart = this.getRenderer();
boolean change = false;
double errorBarMaxYCollect = -Double.MAX_VALUE;
if (chart != null) {
double errorBarMaxY = -Double.MAX_VALUE;
for (final IErrorBarPolicy< ? > errorBarPolicy : this.m_errorBarPolicies) {
if (errorBarPolicy.isShowPositiveYErrors()) {
errorBarMaxY = errorBarPolicy.getYError(this.m_maxY);
if (errorBarMaxY > errorBarMaxYCollect) {
errorBarMaxYCollect = errorBarMaxY;
}
}
}
}
final double absoluteMax = errorBarMaxYCollect + this.m_maxY;
if (!MathUtil.assertEqual(this.m_maxYErrorBar, absoluteMax, 0.00000001)) {
this.m_maxYErrorBar = absoluteMax;
change = true;
}
return change;
}
示例9: maxXSearch
import info.monitorenter.gui.chart.Chart2D; //导入依赖的package包/类
/**
* Internal search for the maximum x value that is only invoked if no cached
* value is at hand or bounds have changed by adding new points.
* <p>
* The result is assigned to the property maxX.
* <p>
*
* @see #getMaxX()
*/
protected void maxXSearch() {
if (Chart2D.DEBUG_THREADING) {
System.out.println("trace.maxXSearch, 0 locks");
}
synchronized (this) {
if (Chart2D.DEBUG_THREADING) {
System.out.println("trace.maxXSearch, 1 locks");
}
double ret = -Double.MAX_VALUE;
ITracePoint2D tmpoint = null;
double tmp;
final Iterator<ITracePoint2D> it = this.iterator();
while (it.hasNext()) {
tmpoint = it.next();
tmp = tmpoint.getX();
if (tmp > ret) {
ret = tmp;
}
}
this.m_maxX = ret;
}
// compute the extra amount in case of error bar painters:
this.expandMaxXErrorBarBounds();
}
示例10: createTraceStrokesMenu
import info.monitorenter.gui.chart.Chart2D; //导入依赖的package包/类
/**
* Creates a menu for choosing the {@link Stroke} of the given trace.
* <p>
*
* @param chart
* needed to adapt the basic ui properties to (font, foreground
* color, background color).
* @param trace
* the trace to set the stroke of.
* @param adaptUI2Chart
* if true the menu will adapt it's basic UI properies (font,
* foreground and background color) to the given chart.
* @return a menu for choosing the stroke of the given trace.
*/
public JMenu createTraceStrokesMenu(final Chart2D chart, final ITrace2D trace,
final boolean adaptUI2Chart) {
JMenuItem item;
// strokes
JMenu strokesMenu;
if (adaptUI2Chart) {
strokesMenu = new PropertyChangeMenu(chart, "Stroke",
new BasicPropertyAdaptSupport.RemoveAsListenerFromComponentIfTraceIsDropped(trace));
} else {
strokesMenu = new JMenu("Stroke");
}
for (int i = 0; i < this.m_strokes.length; i++) {
if (adaptUI2Chart) {
item = new PropertyChangeMenuItem(chart, new Trace2DActionSetStroke(trace,
this.m_strokeNames[i], this.m_strokes[i]),
new BasicPropertyAdaptSupport.RemoveAsListenerFromComponentIfTraceIsDropped(trace));
} else {
item = new JMenuItem(new Trace2DActionSetStroke(trace, this.m_strokeNames[i],
this.m_strokes[i]));
}
strokesMenu.add(item);
}
return strokesMenu;
}
示例11: getAxis
import info.monitorenter.gui.chart.Chart2D; //导入依赖的package包/类
/**
* Returns the axis that is controlled.
* <p>
* Note that several calls may return different instances (
* <code>a.getAxis() == a.getAxis()</code> may be false) in case the
* corresponding chart of the former axis gets a new axis assigned.
* <p>
* Note that this action only works for the first x axis / first y axis:
* Additional axes cannot be handled by now.
* <p>
*
* @return the axis that is controlled.
*/
protected IAxis<?> getAxis() {
// update in case the corresponding chart has a new axis:
IAxis<?> axis = null;
switch (this.m_axis) {
case Chart2D.X:
axis = this.m_chart.getAxisX();
break;
case Chart2D.Y:
axis = this.m_chart.getAxisY();
break;
default:
break;
}
return axis;
}
示例12: plot
import info.monitorenter.gui.chart.Chart2D; //导入依赖的package包/类
public static void plot (String title, String xlabel, String ylabel, double[] data) {
//////////////////////////////////
// Create a chart:
//////////////////////////////////
Chart2D chart = new Chart2D();
// Create an ITrace:
ITrace2D trace = new Trace2DSimple();
// Add the trace to the chart. This has to be done before adding points
chart.addTrace(trace);
// Add all points, as it is static:
for (int i = 0; i < data.length; i++) {
trace.addPoint(i, data[i]);
}
chart.getAxisX().setAxisTitle(new AxisTitle(xlabel));
chart.getAxisY().setAxisTitle(new AxisTitle(ylabel));
// Make it visible:
// Create a frame.
JFrame frame = new JFrame(title);
// add the chart to the frame:
frame.getContentPane().add(chart);
frame.setSize(Toolkit.getDefaultToolkit().getScreenSize().width, 400);
// Enable the termination button [cross on the upper right edge]:
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
frame.setVisible(true);
}
示例13: ChartPanel
import info.monitorenter.gui.chart.Chart2D; //导入依赖的package包/类
public ChartPanel(String... params) {
super(new BorderLayout());
int historySize = 200;
chart = new Chart2D();
chart.setBorder(new EmptyBorder(0,0,0,0));
//chart.setSize(200,200);
chart.setUseAntialiasing(true);
chart.setBackground(Color.BLACK);
chart.setForeground(Color.WHITE);
chart.setGridColor(Color.darkGray);
for (IAxis left : chart.getAxesYLeft()) {
left.setAxisTitle(new AxisTitle(""));
left.setPaintGrid(true);
}
for (IAxis bottom : chart.getAxesXBottom()) {
bottom.setVisible(false);
}
for (String p : params) {
Trace2DLtd t = new Trace2DLtd(historySize, p);
t.setColor(Color.getHSBColor( ((float)(p.hashCode()%1024))/1024.0f, 0.5f, 1.0f));
chart.addTrace(t);
this.params.put(p, t);
}
add(chart, BorderLayout.CENTER);
}
示例14: MinimalStaticChartWithNanValues
import info.monitorenter.gui.chart.Chart2D; //导入依赖的package包/类
/**
* Defcon.
*/
private MinimalStaticChartWithNanValues() {
this.setLayout(new BorderLayout());
Chart2D chart = new Chart2D();
// Create an ITrace:
// Note that dynamic charts need limited amount of values!!!
// ITrace2D trace = new Trace2DLtd(200);
ITrace2D trace = new Trace2DSimple();
trace.setColor(Color.RED);
// Add the trace to the chart:
chart.addTrace(trace);
// Add all points, as it is static:
trace.addPoint(0, 0);
trace.addPoint(1, 10);
trace.addPoint(2, Double.NaN);
trace.addPoint(3, 10);
trace.addPoint(4, 15);
trace.addPoint(5, Double.NaN);
trace.addPoint(6, 16);
trace.addPoint(7, 14);
trace.addPoint(8, 13);
chart.setToolTipType(Chart2D.ToolTipType.VALUE_SNAP_TO_TRACEPOINTS);
// Make it visible:
this.add(chart, BorderLayout.CENTER);
}
示例15: paintComponent
import info.monitorenter.gui.chart.Chart2D; //导入依赖的package包/类
/**
* Finalized to enforce using
* <code>{@link #paintAnnotation(Graphics, Chart2D, ITrace2D, ITracePoint2D)}</code>.
*
* @see javax.swing.JComponent#paintComponent(java.awt.Graphics)
*/
@Override
protected final synchronized void paintComponent(final Graphics g) {
super.paintComponent(g);
// NPE candidate, but must never be null by contract. So exceptions are
// welcome to fix programming errors.
ITrace2D trace = this.m_annotatedPoint.getListener();
Chart2D chart = trace.getRenderer();
this.paintAnnotation(g, chart, trace, this.m_annotatedPoint);
}