Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.java4less.rchart.swing
Class JChartViewer

    java.lang.Object
      |
      +--java.awt.Component
            |
            +--java.awt.Container
                  |
                  +--javax.swing.JComponent
                        |
                        +--javax.swing.JPanel
                              |
                              +--com.java4less.rchart.swing.JChartViewer

All Implemented Interfaces:
  javax.accessibility.Accessible, java.awt.event.ActionListener, java.awt.event.AdjustmentListener, java.util.EventListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable

public class JChartViewer
extends javax.swing.JPanel
implements java.awt.event.AdjustmentListener, java.awt.event.ActionListener

    This class is a JPanel which can be added to any JPanel or JFrame. The viewer implements the following features:
    - It displays the chart you set with the setChart() method.
    - It implements scroll bars and zoom in/out buttons.
    - It can automatically change the cursor when the pointer moves over a value in the chart.

    Example of use:

    public class SimpleJExample extends JFrame  {

            JChartViewer chartViewer= new JChartViewer();

            public SimpleJExample() {
                    this.setTitle("RChart for Swing example");
                    this.setResizable(false);
                    this.getContentPane().setLayout(new java.awt.BorderLayout());
                    this.setSize(new Dimension(500,500));
                    this.getContentPane().add("Center", chartViewer);

                    this.doLayout();

                    // create default chart
                    ChartLoader loader=new ChartLoader();
                    loader.loadFromFile("examples/lineChart.txt",true);
                    chartViewer.setChart(loader.build(false,false));
                    this.show();

            }

    }

See Also:
  Serialized Form

Field Summary
`boolean` | `allowZoom` if TRUE the +/- zoom buttons will be made visible.
`boolean` | `changePointer` change mouse pointer when we are over a point
`int` | `currentZoom` current value of zoom (initial value is 100)
`int` | `maxZoom` maximum zoom in %.
`int` | `minZoom` minimum zoom in %.
`int` | `zoomIncrement` zoom increment in % for the +/- buttons.

Fields inherited from class javax.swing.JComponent
`TOOL_TIP_TEXT_KEY, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW`

Fields inherited from class java.awt.Component
`BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT`

Fields inherited from interface java.awt.image.ImageObserver
`ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH`

Constructor Summary
`JChartViewer()` constructor

Method Summary
`void` | `actionPerformed(java.awt.event.ActionEvent e)` Action Listener: user clicked on the minus or plus button
`void` | `adjustmentValueChanged(java.awt.event.AdjustmentEvent e)` Adjustment listener: scroll bar moved
`Chart` | `getChart()` get chart to display
`java.awt.Dimension` | `getPreferredSize()` preferred size
`void` | `redrawChart()` force the chart to be repainted
`void` | `setChart(Chart c)` set chart to display

Methods inherited from class javax.swing.JPanel
`getAccessibleContext, getUI, getUIClassID, setUI, updateUI`

Methods inherited from class javax.swing.JComponent
`addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintImmediately, paintImmediately, print, printAll, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update`

Methods inherited from class java.awt.Container
`add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, transferFocusBackward, transferFocusDownCycle, validate`

Methods inherited from class java.awt.Component
`action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, createImage, createImage, createVolatileImage, createVolatileImage, dispatchEvent, enable, enableInputMethods, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle`

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### allowZoom

    public boolean allowZoom

  if TRUE the +/- zoom buttons will be made visible.

### maxZoom

    public int maxZoom

  maximum zoom in %. The default is 300.

### minZoom

    public int minZoom

  minimum zoom in %. The default is 50.

### currentZoom

    public int currentZoom

  current value of zoom (initial value is 100)

### zoomIncrement

    public int zoomIncrement

  zoom increment in % for the +/- buttons. The default is 25.

### changePointer

    public boolean changePointer

  change mouse pointer when we are over a point

Constructor Detail

### JChartViewer

    public JChartViewer()

  constructor

Method Detail

### getPreferredSize

    public java.awt.Dimension getPreferredSize()

  preferred size

  Overrides:
    `getPreferredSize` in class `javax.swing.JComponent`

### getChart

    public Chart getChart()

  get chart to display

  Returns:

### setChart

    public void setChart(Chart c)

  set chart to display

  Parameters:
    `c` -

### redrawChart

    public void redrawChart()

  force the chart to be repainted

### adjustmentValueChanged

    public void adjustmentValueChanged(java.awt.event.AdjustmentEvent e)

  Adjustment listener: scroll bar moved

  Specified by:
    `adjustmentValueChanged` in interface `java.awt.event.AdjustmentListener`
  Parameters:
    `e` -

### actionPerformed

    public void actionPerformed(java.awt.event.ActionEvent e)

  Action Listener: user clicked on the minus or plus button

  Specified by:
    `actionPerformed` in interface `java.awt.event.ActionListener`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD