public abstract class GraphGeneral extends JPanel implements Printable
Graph
class builds a panel which displays a graph
according to the data stored in the DataArray
. Extends JPanel since
the graph is returned in a panel (it can be used in other applications or
embedded in a frame. Implements Printable, so we can print the graph, and
ComponentListener, needed to listen to a resize event.
This class should be sub-classed in order to build a specific graph type (i.e.
a 2D graph, piper diagram or 3D, later)Modifier and Type | Class and Description |
---|---|
class |
GraphGeneral.DragListener
Drag listener, does the actual painting during dragging.
|
class |
GraphGeneral.GraphMouseListener
GraphMouseListener, allows to drag'n drop with the mouse.
|
JComponent.AccessibleJComponent
Component.BaselineResizeBehavior
Modifier and Type | Field and Description |
---|---|
JMenuItem |
m_default |
JMenuItem |
m_edit |
JMenuItem |
m_refresh |
float |
scalingFrame |
float |
scalingFrameX |
float |
scalingFrameY |
TOOL_TIP_TEXT_KEY, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
NO_SUCH_PAGE, PAGE_EXISTS
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor and Description |
---|
GraphGeneral(GraphSettings gs)
Main constructor.
|
GraphGeneral(JPlot jp,
GraphSettings gs)
Main constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
arrowCoords(int x1,
int y1,
int x2,
int y2,
int x3,
int y3) |
void |
calcCoords(int index,
int x,
int y,
double dist,
double dirn) |
void |
calcValues(int x1,
int y1,
int x2,
int y2) |
void |
calcValuesQuad(int x1,
int y1,
int x2,
int y2) |
void |
clear()
Clear the graph.
|
void |
drawArrow(Graphics g,
int x1,
int y1,
int x2,
int y2)
Another way with closed ends
|
void |
drawArrow2(org.freehep.graphics2d.VectorGraphics g,
int x1,
int y1,
int x2,
int y2)
Draw arrow
this allows you to draw an arrow with
headlength (headsize),
headwidth (headsize - difference),
hedheight (factor (relative to headlength)),
|
void |
drawDashedLine(org.freehep.graphics2d.VectorGraphics g,
int x1,
int y1,
int x2,
int y2,
double dashlength,
double spacelength)
draw dotted or dashed lines
|
void |
drawPolylineArrow(Graphics g,
int[] xPoints,
int[] yPoints,
int headLength,
int headwidth)
Draw arrow
|
static String |
formatNumber(double num,
int n)
formats a double precision number such that it is correctly rounded for
output.
|
Dimension |
getMinimumSize()
Get the minimum size of this component.
|
static int |
getNumDigits(double num)
Return the number of digits required to display the given number.
|
Dimension |
getPreferredSize()
Get the preferred size of this component.
|
static double |
log10(double x)
Returns the log10 of a double value.
|
void |
paintComponent(Graphics g)
Overloaded paintComponent, is called at each repaint.
|
int |
print(Graphics g,
PageFormat pageFormat,
int pageIndex)
Prints the graph.
|
void |
resetLabelPositions(double w0,
double h0,
double w1,
double h1) |
void |
show(Vector data)
Draws the graph on the graphics canvas of this panel.
|
abstract double |
toUserX(int x)
Returns the X-value scaled to the data-availability.
|
abstract double |
toUserY(int x)
Returns the Y-value scaled to the data-availability.
|
abstract double |
toX(double x)
Returns the X-value scaled to the pixel-availability.
|
abstract double |
toY(double y)
Returns the Y-value scaled to the pixel-availability.
|
getAccessibleContext, getUI, getUIClassID, setUI, updateUI
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintImmediately, paintImmediately, print, printAll, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
add, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, createImage, createImage, createVolatileImage, createVolatileImage, dispatchEvent, enable, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, 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, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
public JMenuItem m_edit
public JMenuItem m_default
public JMenuItem m_refresh
public float scalingFrame
public float scalingFrameY
public float scalingFrameX
public GraphGeneral(JPlot jp, GraphSettings gs)
jp
- JPlot instance (parent).gs
- container with all the graph settings.public GraphGeneral(GraphSettings gs)
gs
- container with all the graph settings.public Dimension getMinimumSize()
getMinimumSize
in class JComponent
public void clear()
public Dimension getPreferredSize()
getPreferredSize
in class JComponent
public static double log10(double x)
x
- valuepublic static int getNumDigits(double num)
public static String formatNumber(double num, int n)
num
- number to be formattedn
- number of digits (accuracy) after the decimal point.public abstract double toX(double x)
x
- real x-value (as introduced by the data)public abstract double toY(double y)
y
- real y-value (as introduced by the data)public abstract double toUserX(int x)
x
- integer x-value (as introduced by the pixels)public abstract double toUserY(int x)
x
- integer x-value (as introduced by the pixels)public void show(Vector data)
data
- vector of Data Array vectors with the data pointspublic void resetLabelPositions(double w0, double h0, double w1, double h1)
public void paintComponent(Graphics g)
paintComponent
in class JComponent
g
- graphics contextpublic int print(Graphics g, PageFormat pageFormat, int pageIndex) throws PrinterException
print
in interface Printable
g
- graphics instance, to which we print the graph.pageFormat
- format of the pagepageIndex
- index of the pagePrinterException
public void drawPolylineArrow(Graphics g, int[] xPoints, int[] yPoints, int headLength, int headwidth)
g
- xPoints
- x1,x2 positionsyPoints
- y1,y2 positionsheadLength
- head lengthheadwidth
- head widthpublic void drawArrow(Graphics g, int x1, int y1, int x2, int y2)
public void calcValues(int x1, int y1, int x2, int y2)
public void calcValuesQuad(int x1, int y1, int x2, int y2)
public void calcCoords(int index, int x, int y, double dist, double dirn)
public void arrowCoords(int x1, int y1, int x2, int y2, int x3, int y3)
public void drawArrow2(org.freehep.graphics2d.VectorGraphics g, int x1, int y1, int x2, int y2)
g
- x1
- y1
- x2
- y2
- public void drawDashedLine(org.freehep.graphics2d.VectorGraphics g, int x1, int y1, int x2, int y2, double dashlength, double spacelength)
Jas4pp 1.5 © Java Analysis Studio for Particle Physics