/*
* -------------------------------------------------------------------------
* $Id: Pick.java,v 1.2 1999/12/16 18:49:49 brophy Exp $
* -------------------------------------------------------------------------
* Copyright (c) 1999 Visual Numerics Inc. All Rights Reserved.
*
* This software is confidential information which is proprietary to
* and a trade secret of Visual Numerics, Inc. Use, duplication or
* disclosure is subject to the terms of an appropriate license
* agreement.
*
* VISUAL NUMERICS MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE
* SUITABILITY OF THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING
* BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. VISUAL
* NUMERICS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE
* AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR
* ITS DERIVATIVES.
*--------------------------------------------------------------------------
*/
package com.imsl.demo.chart;
import com.imsl.chart.*;
import java.awt.*;
import java.awt.event.*;
import java.applet.Applet;
public class Pick extends Applet implements PickListener, MouseListener
{
Chart chart = null;
Bar bar;
final static double x[] = {0, 1, 2, 3};
final static double y[] = {4, 1, 2, 5};
public void init()
{
chart = new Chart(this);
chart.setDoubleBuffering(true);
AxisXY axis = new AxisXY(chart);
axis.getAxisX().getAxisLabel().setPaint(false);
axis.getAxisX().getMajorTick().setPaint(false);
bar = new Bar(axis, x, y);
bar.setFillColor(Color.blue);
bar.setFillOutlineType(Bar.FILL_TYPE_SOLID);
bar.setBarWidth(0.5);
bar.addPickListener(this);
addMouseListener(this);
}
public void update(Graphics g)
{
paint(g);
}
public void paint(Graphics g)
{
chart.paint(g);
}
public void mouseClicked(MouseEvent e)
{
chart.pick(e);
}
public void mousePressed(MouseEvent e)
{
}
public void mouseReleased(MouseEvent e)
{
}
public void mouseEntered(MouseEvent e)
{
}
public void mouseExited(MouseEvent e)
{
}
public void pickPerformed(PickEvent event)
{
ChartNode node = event.getNode();
int count = node.getIntegerAttribute("pick.count", 0);
count++;
node.setAttribute("pick.count", new Integer(count));
Color color = ((count%2==0) ? Color.blue : Color.red);
node.setFillColor(color);
node.setLineColor(color);
repaint();
}
public static void main(String argv[])
{
Pick ex = null;
Frame frame = new Frame();
ex = new Pick();
frame.add(ex);
ex.init();
frame.setSize(new Dimension(400,400));
frame.show();
}
}